reintroduce anyhow

This commit is contained in:
marin postma 2021-06-15 17:39:07 +02:00
parent 439db1aae0
commit 02277ec2cf
No known key found for this signature in database
GPG key ID: 6088B7721C3E39F9
36 changed files with 110 additions and 154 deletions

View file

@ -22,7 +22,7 @@ pub enum AuthenticationError {
impl ErrorCode for AuthenticationError {
fn error_code(&self) -> Code {
match self {
AuthenticationError ::MissingAuthorizationHeader => Code::MissingAuthorizationHeader,
AuthenticationError::MissingAuthorizationHeader => Code::MissingAuthorizationHeader,
AuthenticationError::InvalidToken(_) => Code::InvalidToken,
}
}
@ -62,11 +62,7 @@ macro_rules! response_error {
};
}
response_error!(
IndexControllerError,
AuthenticationError
);
response_error!(IndexControllerError, AuthenticationError);
impl Serialize for ResponseError {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
@ -114,7 +110,8 @@ impl<E: Error> ErrorCode for PayloadError<E> {
}
impl<E> From<PayloadError<E>> for ResponseError
where E: Error + Sync + Send + 'static
where
E: Error + Sync + Send + 'static,
{
fn from(other: PayloadError<E>) -> Self {
ResponseError {
@ -124,7 +121,8 @@ where E: Error + Sync + Send + 'static
}
pub fn payload_error_handler<E>(err: E) -> ResponseError
where E: Error + Sync + Send + 'static
where
E: Error + Sync + Send + 'static,
{
let error = PayloadError(err);
error.into()