pub enum ServiceError {
Show 19 variants
Database(Error),
NotFound,
Conflict,
ConflictDetails {
message: String,
details: Vec<ErrorDetail>,
},
BadRequest(String),
TooManyRequests(String),
Unauthorized,
UnauthorizedMessage(String),
Forbidden(String),
Internal(String),
Validation(String),
Io(Error),
Zip(ZipError),
Docker(String),
Runner(String),
RunnerCapacity(String),
Base64,
ValidationDetails {
message: String,
details: Vec<ErrorDetail>,
},
PayloadTooLarge(String),
}Expand description
Transport-neutral backend error used across shared services and workflows.
Variants§
Database(Error)
NotFound
Conflict
ConflictDetails
BadRequest(String)
TooManyRequests(String)
Forbidden(String)
Internal(String)
Validation(String)
Io(Error)
Zip(ZipError)
Docker(String)
Runner(String)
RunnerCapacity(String)
Base64
ValidationDetails
PayloadTooLarge(String)
Implementations§
Source§impl ServiceError
impl ServiceError
Sourcepub fn bad_request(message: impl Into<String>) -> Self
pub fn bad_request(message: impl Into<String>) -> Self
Builds a bad request error with a public message.
Sourcepub fn validation_failed(
message: impl Into<String>,
details: impl Into<Vec<ErrorDetail>>,
) -> Self
pub fn validation_failed( message: impl Into<String>, details: impl Into<Vec<ErrorDetail>>, ) -> Self
Builds a field validation error with structured details.
Sourcepub fn conflict_with_details(
message: impl Into<String>,
details: impl Into<Vec<ErrorDetail>>,
) -> Self
pub fn conflict_with_details( message: impl Into<String>, details: impl Into<Vec<ErrorDetail>>, ) -> Self
Builds a conflict error with structured field details.
Sourcepub fn too_many_requests(message: impl Into<String>) -> Self
pub fn too_many_requests(message: impl Into<String>) -> Self
Builds a quota/rate-limit error with a public message.
Builds an unauthorized error with a public message.
Sourcepub fn internal(message: impl Into<String>) -> Self
pub fn internal(message: impl Into<String>) -> Self
Builds an internal error whose message must be redacted at HTTP boundaries.
Sourcepub fn code(&self) -> ServiceErrorCode
pub fn code(&self) -> ServiceErrorCode
Returns the stable public error code.
Sourcepub fn public_message(&self) -> Cow<'_, str>
pub fn public_message(&self) -> Cow<'_, str>
Returns the safe public message for API clients.
Sourcepub fn details(&self) -> &[ErrorDetail]
pub fn details(&self) -> &[ErrorDetail]
Returns structured validation details for API clients.
Sourcepub fn is_internal(&self) -> bool
pub fn is_internal(&self) -> bool
Returns whether this error should be logged as an internal application failure.
Sourcepub fn unique_violation_as_conflict(self) -> Self
pub fn unique_violation_as_conflict(self) -> Self
Maps a raw SQL unique-constraint failure into the domain conflict kind.
Trait Implementations§
Source§impl Debug for ServiceError
impl Debug for ServiceError
Source§impl Display for ServiceError
impl Display for ServiceError
Source§impl Error for ServiceError
impl Error for ServiceError
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 ServiceError
impl From<Error> for ServiceError
Source§impl From<Error> for ServiceError
impl From<Error> for ServiceError
Auto Trait Implementations§
impl !RefUnwindSafe for ServiceError
impl !UnwindSafe for ServiceError
impl Freeze for ServiceError
impl Send for ServiceError
impl Sync for ServiceError
impl Unpin for ServiceError
impl UnsafeUnpin for ServiceError
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