1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-04-20 06:54:46 +00:00

improve the From impl for AuthErrorOrOther #20

This commit is contained in:
Dominic 2020-05-20 19:50:17 +02:00
parent 0b06528742
commit 912f030bfd
Signed by: msrd0
GPG key ID: DCC8C247452E98F9
3 changed files with 26 additions and 9 deletions

View file

@ -62,8 +62,9 @@ pub enum AuthErrorOrOther<E>
#[status(FORBIDDEN)]
#[display("Forbidden")]
Forbidden,
#[status(INTERNAL_SERVER_ERROR)]
#[display("{0}")]
Other(#[from] E)
Other(E)
}
impl<E> From<AuthError> for AuthErrorOrOther<E>
@ -76,6 +77,17 @@ impl<E> From<AuthError> for AuthErrorOrOther<E>
}
}
impl<E, F> From<F> for AuthErrorOrOther<E>
where
// TODO https://gitlab.com/msrd0/gotham-restful/-/issues/20
F : std::error::Error + Into<E>
{
fn from(err : F) -> Self
{
Self::Other(err.into())
}
}
/**
This return type can be used to map another `ResourceResult` that can only be returned if the
client is authenticated. Otherwise, an empty _403 Forbidden_ response will be issued. Use can