pub struct OciError {
pub code: OciErrorCode,
pub message: String,
pub detail: Option<Value>,
pub status_override: Option<StatusCode>,
}Expand description
The error type returned by every handler in this crate.
It carries both the spec-defined OciErrorCode (which determines
the JSON code and HTTP status) and a free-form message. An optional
status override covers cases like 405 Method Not Allowed for a
manifest DELETE-by-tag, which spec §3.1 doesn’t have a dedicated
code for.
Fields§
§code: OciErrorCodeSpec-defined error code.
message: StringHuman-readable message.
detail: Option<Value>Machine-readable detail, forwarded into the response body.
status_override: Option<StatusCode>Optional status override (e.g. 405 for DELETE-by-tag).
Implementations§
Source§impl OciError
impl OciError
Sourcepub fn new(code: OciErrorCode, message: impl Into<String>) -> Self
pub fn new(code: OciErrorCode, message: impl Into<String>) -> Self
Build a new error from a code and message.
Sourcepub fn with_detail(self, detail: Value) -> Self
pub fn with_detail(self, detail: Value) -> Self
Attach a JSON detail payload to the error.
Sourcepub fn with_status(self, status: StatusCode) -> Self
pub fn with_status(self, status: StatusCode) -> Self
Override the HTTP status independent of the error code’s default.
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Final HTTP status to return.
Sourcepub fn body(&self) -> OciErrorBody
pub fn body(&self) -> OciErrorBody
Build the JSON body.
Trait Implementations§
Source§impl Error for OciError
impl Error for OciError
1.30.0 · 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 From<BlobStoreError> for OciError
Map a ferro_blob_store::BlobStoreError onto an OciError.
impl From<BlobStoreError> for OciError
Map a ferro_blob_store::BlobStoreError onto an OciError.
Called at the edge of every handler so the protocol crate can use
the workspace-wide Result type while still surfacing spec-shaped
responses.
Source§fn from(err: BlobStoreError) -> Self
fn from(err: BlobStoreError) -> Self
Source§impl IntoResponse for OciError
impl IntoResponse for OciError
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Auto Trait Implementations§
impl Freeze for OciError
impl RefUnwindSafe for OciError
impl Send for OciError
impl Sync for OciError
impl Unpin for OciError
impl UnsafeUnpin for OciError
impl UnwindSafe for OciError
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, S> Handler<IntoResponseHandler, S> for T
impl<T, S> Handler<IntoResponseHandler, S> for T
Source§fn call(
self,
_req: Request<Body>,
_state: S,
) -> <T as Handler<IntoResponseHandler, S>>::Future
fn call( self, _req: Request<Body>, _state: S, ) -> <T as Handler<IntoResponseHandler, S>>::Future
Source§fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
tower::Layer to the handler. Read moreSource§fn with_state(self, state: S) -> HandlerService<Self, T, S>
fn with_state(self, state: S) -> HandlerService<Self, T, S>
Service by providing the stateSource§impl<H, T> HandlerWithoutStateExt<T> for H
impl<H, T> HandlerWithoutStateExt<T> for H
Source§fn into_service(self) -> HandlerService<H, T, ()>
fn into_service(self) -> HandlerService<H, T, ()>
Service and no state.Source§fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
MakeService and no state. Read moreSource§fn into_make_service_with_connect_info<C>(
self,
) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
fn into_make_service_with_connect_info<C>( self, ) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
MakeService which stores information
about the incoming connection and has no state. Read more