#[non_exhaustive]pub enum Error {
Validation {
kind: ValidationKind,
message: String,
},
Api {
status: u16,
message: String,
retry_after: Option<RetryAfter>,
source: Option<Box<dyn Error + Send + Sync + 'static>>,
},
NotFound(String),
Timeout {
message: String,
retry_after: Option<RetryAfter>,
source: Option<Box<dyn Error + Send + Sync + 'static>>,
},
Connection {
message: String,
retry_after: Option<RetryAfter>,
source: Option<Box<dyn Error + Send + Sync + 'static>>,
},
Parse {
message: String,
source: Option<Box<dyn Error + Send + Sync + 'static>>,
},
}Expand description
Error type for NSIP operations.
Every variant derives a miette::Diagnostic code and a stable type URI,
and maps to an RFC 9457 Problem Details envelope via
Error::to_problem_details. The fallible-API variants (Error::Api,
Error::Timeout, Error::Connection, Error::Parse) carry an
optional #[source] so the originating reqwest/serde_json error stays
inspectable; the transient variants also carry an optional retry_after.
Maps to the Python exception hierarchy:
Error::Validation—NSIPValidationErrorError::Api—NSIPAPIErrorError::NotFound—NSIPNotFoundErrorError::Timeout—NSIPTimeoutErrorError::Connection—NSIPConnectionErrorError::Parse— deserialization failures
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Validation
Invalid input parameters (validation failure). The kind selects the
specific problem type and guidance; see ValidationKind.
Fields
kind: ValidationKindOperation-specific classification selecting the problem type.
Api
The API returned a non-success HTTP status.
Fields
retry_after: Option<RetryAfter>Retry delay parsed from the upstream Retry-After header, for
transient (429 / 5xx) responses.
NotFound(String)
The requested resource was not found (HTTP 404).
Timeout
The request timed out.
Fields
retry_after: Option<RetryAfter>Suggested retry delay, where one is known.
Connection
Failed to connect to the API.
Fields
retry_after: Option<RetryAfter>Suggested retry delay, where one is known.
Parse
Failed to parse the API response.
Implementations§
Source§impl Error
impl Error
Sourcepub const fn slug_path(&self) -> &'static str
pub const fn slug_path(&self) -> &'static str
<domain>/<slug> path component for this error’s type URI, e.g.
api/timeout. One slug per variant (the Api variant carries its HTTP
status in the status field rather than splitting into sub-slugs).
Sourcepub fn type_uri(&self) -> String
pub fn type_uri(&self) -> String
Stable type URI under the repository’s docs/reference/errors/ tree.
Sourcepub const fn title(&self) -> &'static str
pub const fn title(&self) -> &'static str
One-sentence, type-level title (stable across occurrences).
Sourcepub const fn exit_code(&self) -> i32
pub const fn exit_code(&self) -> i32
Process exit code for this error.
Aligned with sysexits.h where applicable:
1— caller error (bad input, 4xx, not found).3— environment error (unparseable upstream payload).75—EX_TEMPFAIL, transient (timeout, connection, 429, 5xx);retry_afteris populated where a delay is known.
Sourcepub const fn status_code(&self) -> u16
pub const fn status_code(&self) -> u16
HTTP-class status for the Problem Details envelope.
Sourcepub fn suggested_fix(&self) -> Option<String>
pub fn suggested_fix(&self) -> Option<String>
Free-text recovery action for this error, or None when there is no
deterministic fix. Applicability markers for each fix are catalogued in
docs/reference/errors/README.md, keyed by type.
Sourcepub fn retry_after(&self) -> Option<RetryAfter>
pub fn retry_after(&self) -> Option<RetryAfter>
Retry delay for transient errors, sourced from the upstream
Retry-After header where available. None for terminal errors.
Sourcepub fn to_problem_details(&self, command: &str) -> ProblemDetails
pub fn to_problem_details(&self, command: &str) -> ProblemDetails
Build the RFC 9457 Problem Details object for this error.
command seeds the instance URN — pass the CLI subcommand or MCP tool
name (e.g. "search"), or "nsip" if unknown.
§Examples
let err = nsip::Error::NotFound("LPN 123".to_string());
let pd = err.to_problem_details("details");
assert_eq!(pd.status, 404);
assert!(pd.instance.starts_with("urn:nsip:details:"));Source§impl Error
impl Error
Sourcepub fn validation(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
Construct a generic Error::Validation (ValidationKind::Other).
Sourcepub fn validation_kind(kind: ValidationKind, message: impl Into<String>) -> Self
pub fn validation_kind(kind: ValidationKind, message: impl Into<String>) -> Self
Construct a Error::Validation with an explicit ValidationKind.
Sourcepub fn empty_lpn_id() -> Self
pub fn empty_lpn_id() -> Self
ValidationKind::EmptyLpnId — an LPN ID argument was empty.
Sourcepub fn invalid_breed_id(message: impl Into<String>) -> Self
pub fn invalid_breed_id(message: impl Into<String>) -> Self
ValidationKind::InvalidBreedId — a breed ID was non-positive or unparseable.
Sourcepub fn page_range(message: impl Into<String>) -> Self
pub fn page_range(message: impl Into<String>) -> Self
ValidationKind::PageRange — a pagination parameter was out of range.
Sourcepub fn empty_search(message: impl Into<String>) -> Self
pub fn empty_search(message: impl Into<String>) -> Self
ValidationKind::EmptySearch — a search request carried no filter.
Sourcepub fn compare_arity(message: impl Into<String>) -> Self
pub fn compare_arity(message: impl Into<String>) -> Self
ValidationKind::CompareArity — comparison given <2 or >5 animals.
Sourcepub fn missing_argument(message: impl Into<String>) -> Self
pub fn missing_argument(message: impl Into<String>) -> Self
ValidationKind::MissingArgument — a required MCP argument was absent.
Sourcepub fn unknown_resource(message: impl Into<String>) -> Self
pub fn unknown_resource(message: impl Into<String>) -> Self
ValidationKind::UnknownResource — an MCP resource URI was unknown.
Sourcepub fn invalid_cursor(message: impl Into<String>) -> Self
pub fn invalid_cursor(message: impl Into<String>) -> Self
ValidationKind::InvalidCursor — an MCP pagination cursor was bad.
Sourcepub fn unknown_transport(message: impl Into<String>) -> Self
pub fn unknown_transport(message: impl Into<String>) -> Self
ValidationKind::UnknownTransport — an unsupported MCP transport.
Sourcepub fn not_found(message: impl Into<String>) -> Self
pub fn not_found(message: impl Into<String>) -> Self
Construct a Error::NotFound from any string-like message.
Sourcepub fn api(status: u16, message: impl Into<String>) -> Self
pub fn api(status: u16, message: impl Into<String>) -> Self
Construct a Error::Api with no retry hint or source.
Sourcepub fn timeout(message: impl Into<String>) -> Self
pub fn timeout(message: impl Into<String>) -> Self
Construct a Error::Timeout with no retry hint or source.
Sourcepub fn connection(message: impl Into<String>) -> Self
pub fn connection(message: impl Into<String>) -> Self
Construct a Error::Connection with no retry hint or source.
Sourcepub fn parse(message: impl Into<String>) -> Self
pub fn parse(message: impl Into<String>) -> Self
Construct a Error::Parse with no source.
Trait Implementations§
Source§impl Diagnostic for Error
impl Diagnostic for Error
Source§fn code(&self) -> Option<Box<dyn Display + '_>>
fn code(&self) -> Option<Box<dyn Display + '_>>
Diagnostic. Ideally also globally unique, and documented
in the toplevel crate’s documentation for easy searching. Rust path
format (foo::bar::baz) is recommended, but more classic codes like
E0123 or enums will work just fine.Source§fn help(&self) -> Option<Box<dyn Display + '_>>
fn help(&self) -> Option<Box<dyn Display + '_>>
Diagnostic. Do you have any
advice for the poor soul who’s just run into this issue?Source§fn url(&self) -> Option<Box<dyn Display + '_>>
fn url(&self) -> Option<Box<dyn Display + '_>>
Diagnostic.Source§fn severity(&self) -> Option<Severity>
fn severity(&self) -> Option<Severity>
ReportHandlers to change the display format
of this diagnostic. Read moreSource§fn source_code(&self) -> Option<&dyn SourceCode>
fn source_code(&self) -> Option<&dyn SourceCode>
Diagnostic’s Diagnostic::labels to.Source§fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
Diagnostic’s Diagnostic::source_codeDiagnostics.Source§fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
Source§impl Error for Error
impl Error for Error
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()
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
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<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more