| 8 | |
| 9 | impl ToStatus for storage::error::Error { |
| 10 | fn status(&self) -> Status { |
| 11 | match self { |
| 12 | storage::error::Error::NotFound(_) => Status::new(Code::NotFound, format!("{}", self)), |
| 13 | storage::error::Error::AlreadyExists(_) => { |
| 14 | Status::new(Code::AlreadyExists, format!("{:#}", self)) |
| 15 | } |
| 16 | storage::error::Error::InvalidEmail => { |
| 17 | Status::new(Code::InvalidArgument, format!("{:#}", self)) |
| 18 | } |
| 19 | storage::error::Error::PasswordTooShort => { |
| 20 | Status::new(Code::InvalidArgument, format!("{:#}", self)) |
| 21 | } |
| 22 | storage::error::Error::PasswordTooLong => { |
| 23 | Status::new(Code::InvalidArgument, format!("{:#}", self)) |
| 24 | } |
| 25 | storage::error::Error::HashPassword(_) => { |
| 26 | Status::new(Code::InvalidArgument, format!("{:#}", self)) |
| 27 | } |
| 28 | storage::error::Error::InvalidUsernameOrPassword => { |
| 29 | Status::new(Code::Unauthenticated, format!("{:#}", self)) |
| 30 | } |
| 31 | storage::error::Error::InvalidPayload(_) => { |
| 32 | Status::new(Code::Internal, format!("{:#}", self)) |
| 33 | } |
| 34 | storage::error::Error::InvalidMIC => { |
| 35 | Status::new(Code::InvalidArgument, format!("{:#}", self)) |
| 36 | } |
| 37 | storage::error::Error::InvalidDevNonce => { |
| 38 | Status::new(Code::InvalidArgument, format!("{:#}", self)) |
| 39 | } |
| 40 | storage::error::Error::Validation(_) => { |
| 41 | Status::new(Code::InvalidArgument, format!("{:#}", self)) |
| 42 | } |
| 43 | storage::error::Error::NotAllowed(_) => { |
| 44 | Status::new(Code::InvalidArgument, format!("{:#}", self)) |
| 45 | } |
| 46 | storage::error::Error::Diesel(_) => Status::new(Code::Internal, format!("{:#}", self)), |
| 47 | storage::error::Error::Anyhow(_) => Status::new(Code::Internal, format!("{:#}", self)), |
| 48 | storage::error::Error::Lrwn(_) => Status::new(Code::Internal, format!("{:#}", self)), |
| 49 | storage::error::Error::TokioJoin(_) => { |
| 50 | Status::new(Code::Internal, format!("{:#}", self)) |
| 51 | } |
| 52 | storage::error::Error::Redis(_) => Status::new(Code::Internal, format!("{:#}", self)), |
| 53 | storage::error::Error::ProstDecode(_) => { |
| 54 | Status::new(Code::Internal, format!("{:#}", self)) |
| 55 | } |
| 56 | storage::error::Error::ValidatorValidate(_) => { |
| 57 | Status::new(Code::InvalidArgument, format!("{:#}", self)) |
| 58 | } |
| 59 | &storage::error::Error::FCntUpAlreadyUpdated(_) => { |
| 60 | Status::new(Code::Internal, format!("{:#}", self)) |
| 61 | } |
| 62 | storage::error::Error::Multi(errors) => { |
| 63 | let errors = errors |
| 64 | .iter() |
| 65 | .map(|e| e.to_string()) |
| 66 | .collect::<Vec<String>>() |
| 67 | .join(", "); |