pub enum DocumentError {
Show 13 variants
EmptyPath,
EmptyValues,
UnknownSegment {
path: String,
segment: String,
},
UnregisteredArray {
path: String,
},
SlugNotFound {
prefix: String,
slug: String,
},
SlugAlreadyExists {
prefix: String,
slug: String,
},
NotTraversable {
path: String,
got: String,
},
TypeMismatch {
path: String,
expected: String,
got: String,
hint: Option<String>,
},
PathNotFound {
path: String,
},
IndexOutOfBounds {
path: String,
index: usize,
len: usize,
},
ParseError {
format: String,
detail: String,
},
IoError {
detail: String,
},
UnsupportedOperation {
format: String,
operation: String,
detail: String,
},
}Variants§
EmptyPath
EmptyValues
UnknownSegment
UnregisteredArray
SlugNotFound
SlugAlreadyExists
NotTraversable
TypeMismatch
PathNotFound
IndexOutOfBounds
ParseError
IoError
UnsupportedOperation
Implementations§
Source§impl DocumentError
impl DocumentError
Sourcepub const fn code(&self) -> &'static str
pub const fn code(&self) -> &'static str
Stable, program-decidable error code for this failure category.
Multiple variants can share a code when callers should handle them in
the same way. In particular, all read-address failures report
document_path_not_found.
Sourcepub fn location(&self) -> Option<String>
pub fn location(&self) -> Option<String>
Best-effort, content-free source location for a parse failure.
Returns e.g. "line 5 column 12" (or "line 5") for a
DocumentError::ParseError, and None for every other variant or
when the underlying parser reported no position. The returned string is
derived from the parser’s position only and never contains document
content, so it is safe to surface even when the parsed file may hold
secrets.
Sourcepub fn redacted_message(&self) -> String
pub fn redacted_message(&self) -> String
A display message with any potentially content-bearing detail removed — safe to surface when the document may hold secrets.
A DocumentError::ParseError renders as failed to parse {format}
(with the location appended when known) and drops
the raw parser detail, which can echo a snippet of the source. Every
other variant renders the same as its [Display], since those carry
only structural context (paths, type and format names), not content.
Sourcepub fn from_serde(path: impl Into<String>, err: impl Display) -> Self
pub fn from_serde(path: impl Into<String>, err: impl Display) -> Self
Wrap a serde deserialization failure as a TypeMismatch so callers that
do a read-modify-write cycle (set_path → serde round-trip) surface a
consistent error style rather than a raw serde message.
Trait Implementations§
Source§impl Clone for DocumentError
impl Clone for DocumentError
Source§fn clone(&self) -> DocumentError
fn clone(&self) -> DocumentError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DocumentError
impl Debug for DocumentError
Source§impl Display for DocumentError
impl Display for DocumentError
Source§impl Error for DocumentError
impl Error for DocumentError
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()