pub struct OperationOutcomeError(/* private fields */);Expand description
A failure as a FHIR OperationOutcome, with the HTTP status it answers
and a record of where it came from.
Boxed so that a Result<T, OperationOutcomeError> is no larger than T
needs: the Ok path pays nothing for the error’s bookkeeping.
Implementations§
Source§impl OperationOutcomeError
impl OperationOutcomeError
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
http_status as a StatusCode.
Source§impl OperationOutcomeError
impl OperationOutcomeError
Sourcepub fn capture_backtraces(enabled: bool)
pub fn capture_backtraces(enabled: bool)
Capture a backtrace for every error that answers 5xx from now on. Off by default: a backtrace costs microseconds to capture and a rejected request does not need one.
pub fn new(source: Option<Source>, outcome: OperationOutcome) -> Self
Sourcepub fn unprocessable(outcome: OperationOutcome) -> Self
pub fn unprocessable(outcome: OperationOutcome) -> Self
An error that answers 422 Unprocessable Entity whatever its issue codes: the request is well formed but cannot be processed as it is, such as a resource that violates an applicable profile.
pub fn fatal(code: BoundCode<IssueType>, diagnostic: String) -> Self
pub fn error(code: BoundCode<IssueType>, diagnostic: String) -> Self
pub fn warning(code: BoundCode<IssueType>, diagnostic: String) -> Self
pub fn information(code: BoundCode<IssueType>, diagnostic: String) -> Self
Sourcepub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Self
pub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Self
Attach the error this one wraps. Prefer this over formatting the cause into the diagnostic: the client keeps the message you wrote and the log gets the whole chain.
Sourcepub fn context(self, message: impl Into<Cow<'static, str>>) -> Self
pub fn context(self, message: impl Into<Cow<'static, str>>) -> Self
Record what the caller was doing when the error passed through. Shows up in the log next to the origin; the client never sees it.
pub fn outcome(&self) -> &OperationOutcome
pub fn push_issue(&mut self, issue: OperationOutcomeIssue)
Sourcepub fn origin(&self) -> &'static Location<'static>
pub fn origin(&self) -> &'static Location<'static>
Where the error was built, or where a ? turned a foreign error into one.
pub fn backtrace(&self) -> Option<&Backtrace>
Sourcepub fn causes(&self) -> impl Iterator<Item = &(dyn Error + 'static)>
pub fn causes(&self) -> impl Iterator<Item = &(dyn Error + 'static)>
The attached source error and everything it in turn was caused by.
Sourcepub fn http_status(&self) -> u16
pub fn http_status(&self) -> u16
The HTTP status the error answers with: an override if set, otherwise the status the first issue’s code maps to.
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Whether the status is 5xx: the server failed, not the request.
Trait Implementations§
Source§impl Debug for OperationOutcomeError
impl Debug for OperationOutcomeError
Source§impl Display for OperationOutcomeError
impl Display for OperationOutcomeError
Source§impl Error for OperationOutcomeError
impl Error for OperationOutcomeError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl IntoResponse for OperationOutcomeError
impl IntoResponse for OperationOutcomeError
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Auto Trait Implementations§
impl !RefUnwindSafe for OperationOutcomeError
impl !UnwindSafe for OperationOutcomeError
impl Freeze for OperationOutcomeError
impl Send for OperationOutcomeError
impl Sync for OperationOutcomeError
impl Unpin for OperationOutcomeError
impl UnsafeUnpin for OperationOutcomeError
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
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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