pub enum Error {
Io(Error),
IoWithPath {
path: PathBuf,
message: String,
},
Config(String),
Json(Error),
Yaml(Error),
NotFound {
resource_type: String,
id: String,
},
FileNotFound {
path: PathBuf,
},
InvalidPath {
path: PathBuf,
reason: String,
},
Parse(String),
Operation(String),
}Expand description
Common error type for Fabryk operations.
All Fabryk crates use this error type or wrap it in their own domain-specific
error types. The variants cover common infrastructure errors; domain-specific
errors should use Operation with a descriptive message or wrap this type.
Variants§
Io(Error)
I/O error (file operations, network, etc.)
IoWithPath
I/O error with path context.
Config(String)
Configuration error.
Json(Error)
JSON serialization/deserialization error.
Yaml(Error)
YAML serialization/deserialization error.
NotFound
Resource not found (file, concept, source, etc.)
FileNotFound
File not found at specific path.
InvalidPath
Invalid path.
Parse(String)
Parse error (malformed content, invalid format).
Operation(String)
Generic operation error (escape hatch for domain-specific errors).
Implementations§
Source§impl Error
impl Error
Sourcepub fn io(err: Error) -> Self
pub fn io(err: Error) -> Self
Create an I/O error.
This is useful when you have an std::io::Error and want to convert
it explicitly (as opposed to using ? with From conversion).
Sourcepub fn io_with_path(err: Error, path: impl Into<PathBuf>) -> Self
pub fn io_with_path(err: Error, path: impl Into<PathBuf>) -> Self
Create an I/O error with path context.
Sourcepub fn not_found(
resource_type: impl Into<String>,
id: impl Into<String>,
) -> Self
pub fn not_found( resource_type: impl Into<String>, id: impl Into<String>, ) -> Self
Create a not-found error with resource type and ID.
Sourcepub fn file_not_found(path: impl Into<PathBuf>) -> Self
pub fn file_not_found(path: impl Into<PathBuf>) -> Self
Create a file-not-found error.
Sourcepub fn not_found_msg(msg: impl Into<String>) -> Self
pub fn not_found_msg(msg: impl Into<String>) -> Self
Create a not-found error with just a message.
This is a convenience method for when you don’t have a specific resource type, or the message already contains the context.
Sourcepub fn invalid_path(path: impl Into<PathBuf>, reason: impl Into<String>) -> Self
pub fn invalid_path(path: impl Into<PathBuf>, reason: impl Into<String>) -> Self
Create an invalid path error.
Sourcepub fn operation(msg: impl Into<String>) -> Self
pub fn operation(msg: impl Into<String>) -> Self
Create an operation error (generic domain-specific error).
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Check if this is a not-found error (any variant).
Sourcepub fn is_path_error(&self) -> bool
pub fn is_path_error(&self) -> bool
Check if this is a path-related error.