multer_derive/
error.rs

1/// An error that ocurred while processing a multipart.
2#[derive(Debug, thiserror::Error)]
3pub enum Error {
4    /// An error ocurred in `multer`.
5    #[error(transparent)]
6    MultipartError(multer::Error),
7
8    /// Other error that ocurred.
9    #[error(transparent)]
10    Other(Box<dyn std::error::Error + Send + Sync>),
11}
12
13impl Error {
14    /// Constructs a new error.
15    pub fn new(error: impl Into<Box<dyn std::error::Error + Send + Sync>>) -> Self {
16        Error::Other(error.into())
17    }
18
19    /// Constructs an error from multer.
20    pub fn from_multer(error: multer::Error) -> Self {
21        Error::MultipartError(error)
22    }
23}
24
25impl From<multer::Error> for Error {
26    fn from(error: multer::Error) -> Self {
27        Error::from_multer(error)
28    }
29}