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:
parent
0b06528742
commit
912f030bfd
3 changed files with 26 additions and 9 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue