pub enum ShaperailError {
NotFound,
Unauthorized,
Forbidden,
Validation(Vec<FieldError>),
Conflict(String),
RateLimited,
Internal(String),
}Expand description
Unified error type used across all Shaperail crates.
Maps to the PRD error response format:
{
"error": {
"code": "NOT_FOUND",
"status": 404,
"message": "Resource not found",
"request_id": "abc-123",
"details": null
}
}Variants§
NotFound
404 — Resource not found.
401 — Missing or invalid authentication.
Forbidden
403 — Authenticated but insufficient permissions.
Validation(Vec<FieldError>)
422 — One or more fields failed validation.
Conflict(String)
409 — Conflict (e.g., unique constraint violation).
RateLimited
429 — Rate limit exceeded.
Internal(String)
500 — Internal server error.
Implementations§
Source§impl ShaperailError
impl ShaperailError
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Returns the HTTP status code for this error.
Sourcepub fn to_error_body(&self, request_id: &str) -> Value
pub fn to_error_body(&self, request_id: &str) -> Value
Builds the PRD-mandated JSON error response body.
The request_id is passed in by the caller (typically from middleware).
Trait Implementations§
Source§impl Debug for ShaperailError
impl Debug for ShaperailError
Source§impl Display for ShaperailError
impl Display for ShaperailError
Source§impl Error for ShaperailError
impl Error for ShaperailError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<Error> for ShaperailError
impl From<Error> for ShaperailError
Source§impl ResponseError for ShaperailError
impl ResponseError for ShaperailError
Source§fn status_code(&self) -> StatusCode
fn status_code(&self) -> StatusCode
Returns appropriate status code for error. Read more
Source§fn error_response(&self) -> HttpResponse
fn error_response(&self) -> HttpResponse
Creates full response for error. Read more
Auto Trait Implementations§
impl Freeze for ShaperailError
impl RefUnwindSafe for ShaperailError
impl Send for ShaperailError
impl Sync for ShaperailError
impl Unpin for ShaperailError
impl UnsafeUnpin for ShaperailError
impl UnwindSafe for ShaperailError
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
Converts
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>
Converts
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