pub struct AuthorizationError {
error_type: <AuthorizationError as BackendError>::ErrorType,
message: String,
source: Option<Error>,
span_trace: Box<SpanTrace>,
backtrace: Box<Backtrace>,
location: Option<&'static Location<'static>>,
}Expand description
Error type used by the authorization checks.
The message is meant to be seen by the user; the source carries the role and action detail that is only useful to whoever is diagnosing the denial.
Build one with authorization_err!:
authorization_err!(Unauthorized, "This course requires authentication to access".to_string());
authorization_err!(InternalServerError, "Failed to fetch user roles".to_string(), original_error);Fields§
§error_type: <AuthorizationError as BackendError>::ErrorType§message: String§source: Option<Error>§span_trace: Box<SpanTrace>§backtrace: Box<Backtrace>§location: Option<&'static Location<'static>>Implementations§
Source§impl AuthorizationError
impl AuthorizationError
Sourcepub fn clean_string(&self, color: ColorChoice) -> String
pub fn clean_string(&self, color: ColorChoice) -> String
Render this error in the clean developer format.
Source§impl AuthorizationError
impl AuthorizationError
Sourcepub fn is_denial(&self) -> bool
pub fn is_denial(&self) -> bool
Whether the check ran and refused, rather than failing to run at all. Consumers that answer a permission question with a boolean read a denial as “no” and everything else as a failure.
Sourcepub fn into_model_error(self) -> Result<ModelError, AuthorizationError>
pub fn into_model_error(self) -> Result<ModelError, AuthorizationError>
Unwraps an AuthorizationErrorType::Model error into the ModelError the check failed
on, so that the caller can apply its own ModelError mapping instead of collapsing
every data-loading failure into a single status code. Any other error is handed back
unchanged.
Trait Implementations§
Source§impl BackendError for AuthorizationError
impl BackendError for AuthorizationError
type ErrorType = AuthorizationErrorType
fn backtrace(&self) -> Option<&Backtrace>
fn error_type(&self) -> &<AuthorizationError as BackendError>::ErrorType
fn message(&self) -> &str
fn span_trace(&self) -> &SpanTrace
Source§fn location(&self) -> Option<&'static Location<'static>>
fn location(&self) -> Option<&'static Location<'static>>
Source§fn new_with_traces_and_location<M, S>(
error_type: <AuthorizationError as BackendError>::ErrorType,
message: M,
source_error: S,
backtrace: Backtrace,
span_trace: SpanTrace,
location: Option<&'static Location<'static>>,
) -> AuthorizationError
fn new_with_traces_and_location<M, S>( error_type: <AuthorizationError as BackendError>::ErrorType, message: M, source_error: S, backtrace: Backtrace, span_trace: SpanTrace, location: Option<&'static Location<'static>>, ) -> AuthorizationError
Source§fn new<M, S>(error_type: Self::ErrorType, message: M, source_error: S) -> Self
fn new<M, S>(error_type: Self::ErrorType, message: M, source_error: S) -> Self
Source§fn new_with_traces<M, S>(
error_type: Self::ErrorType,
message: M,
source_error: S,
backtrace: Backtrace,
span_trace: SpanTrace,
) -> Self
fn new_with_traces<M, S>( error_type: Self::ErrorType, message: M, source_error: S, backtrace: Backtrace, span_trace: SpanTrace, ) -> Self
new but with an explicit backtrace and span trace, e.g. to
preserve a source error’s traces.fn to_different_error<T>( self, new_error_type: <T as BackendError>::ErrorType, new_message: String, ) -> T
Source§impl Debug for AuthorizationError
impl Debug for AuthorizationError
Source§impl Display for AuthorizationError
impl Display for AuthorizationError
Source§impl Error for AuthorizationError
impl Error for AuthorizationError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Source§fn cause(&self) -> Option<&dyn Error>
fn cause(&self) -> Option<&dyn Error>
replaced by Error::source, which can support downcasting
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<AuthorizationError> for ControllerError
impl From<AuthorizationError> for ControllerError
Source§fn from(err: AuthorizationError) -> Self
fn from(err: AuthorizationError) -> Self
Source§impl From<ModelError> for AuthorizationError
impl From<ModelError> for AuthorizationError
Source§fn from(err: ModelError) -> AuthorizationError
fn from(err: ModelError) -> AuthorizationError
Auto Trait Implementations§
impl Freeze for AuthorizationError
impl !RefUnwindSafe for AuthorizationError
impl Send for AuthorizationError
impl Sync for AuthorizationError
impl Unpin for AuthorizationError
impl UnsafeUnpin for AuthorizationError
impl !UnwindSafe for AuthorizationError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ErrorTrace for Twhere
T: BackendError,
impl<T> ErrorTrace for Twhere
T: BackendError,
Source§fn span_trace(&self) -> &SpanTrace
fn span_trace(&self) -> &SpanTrace
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<E> InstrumentError for Ewhere
TracedError<E>: From<E>,
impl<E> InstrumentError for Ewhere
TracedError<E>: From<E>,
§type Instrumented = TracedError<E>
type Instrumented = TracedError<E>
§fn in_current_span(self) -> <E as InstrumentError>::Instrumented
fn in_current_span(self) -> <E as InstrumentError>::Instrumented
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].