#[non_exhaustive]pub enum ServiceError {
InvalidInput(String),
OwnershipDenied {
id: String,
ownership: Ownership,
},
Conflict(String),
Manager {
kind: ManagerFailureKind,
detail: String,
os_code: Option<i32>,
},
}Expand description
Typed service errors. Destructive attempts on Foreign/Unknown fail here.
Error strings produced by crate helpers are capped at
MAX_DIAGNOSTIC_BYTES UTF-8-safe bytes.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidInput(String)
Caller input violates the contract.
OwnershipDenied
The registration is foreign or unknown; destructive mutation denied.
Conflict(String)
The manager reported a conflict (already exists, not found, transitioning).
Manager
A bounded manager call failed.
Fields
kind: ManagerFailureKindThe machine-readable failure classification.
Implementations§
Source§impl ServiceError
impl ServiceError
Sourcepub fn manager(kind: ManagerFailureKind, detail: impl Into<String>) -> Self
pub fn manager(kind: ManagerFailureKind, detail: impl Into<String>) -> Self
Builds a manager failure with the given classification.
The detail is bounded at MAX_DIAGNOSTIC_BYTES UTF-8-safe bytes.
Sourcepub fn manager_with_os_code(
kind: ManagerFailureKind,
detail: impl Into<String>,
os_code: Option<i32>,
) -> Self
pub fn manager_with_os_code( kind: ManagerFailureKind, detail: impl Into<String>, os_code: Option<i32>, ) -> Self
Builds a manager failure that carries a platform error code.
The detail is bounded at MAX_DIAGNOSTIC_BYTES UTF-8-safe bytes. The
code stays reachable through ServiceError::manager_os_code, so a
platform mapping never degrades into a rendered sentence.
Sourcepub fn manager_kind(&self) -> Option<ManagerFailureKind>
pub fn manager_kind(&self) -> Option<ManagerFailureKind>
Returns the manager failure kind, when this is a manager failure.
This is the programmatic discriminator: a consumer matches on the
returned kind instead of inspecting ServiceError::Manager’s detail
text.
Sourcepub fn manager_os_code(&self) -> Option<i32>
pub fn manager_os_code(&self) -> Option<i32>
Returns the platform error code of a manager failure, when the platform supplied a structured one.
Trait Implementations§
Source§impl Clone for ServiceError
impl Clone for ServiceError
Source§impl Debug for ServiceError
impl Debug for ServiceError
Source§impl Display for ServiceError
impl Display for ServiceError
impl Eq for ServiceError
Source§impl Error for ServiceError
impl Error for ServiceError
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()