pub struct ErrorBuilder { /* private fields */ }Expand description
Builder for constructing errors with rich context
This builder enables fluent, ergonomic error construction with additional context.
§Examples
use oxigdal_core::error::OxiGdalError;
use std::path::Path;
let err = OxiGdalError::io_error_builder("Cannot read file")
.with_path(Path::new("/data/file.tif"))
.with_operation("read_raster")
.with_suggestion("Check file permissions")
.build();Implementations§
Source§impl ErrorBuilder
impl ErrorBuilder
Sourcepub fn new(error: OxiGdalError) -> Self
pub fn new(error: OxiGdalError) -> Self
Create a new error builder
Sourcepub fn with_path(self, path: impl AsRef<Path>) -> Self
pub fn with_path(self, path: impl AsRef<Path>) -> Self
Set the file path associated with this error
Sourcepub fn with_operation(self, operation: impl Into<String>) -> Self
pub fn with_operation(self, operation: impl Into<String>) -> Self
Set the operation name that failed
Sourcepub fn with_parameter(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_parameter( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add a parameter key-value pair
Sourcepub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
pub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
Set a custom suggestion (overrides the default suggestion)
Sourcepub fn build(self) -> OxiGdalError
pub fn build(self) -> OxiGdalError
Build the final error, incorporating all context
Note: The additional context is stored and can be retrieved via the
error’s context() method after building.
Sourcepub fn into_error(self) -> OxiGdalError
pub fn into_error(self) -> OxiGdalError
Get the error without building (consumes self)
Sourcepub fn error(&self) -> &OxiGdalError
pub fn error(&self) -> &OxiGdalError
Get a reference to the underlying error
Sourcepub fn operation_name(&self) -> Option<&str>
pub fn operation_name(&self) -> Option<&str>
Get the operation name (if set)
Sourcepub fn parameters(&self) -> &HashMap<String, String>
pub fn parameters(&self) -> &HashMap<String, String>
Get the parameters
Sourcepub fn custom_suggestion(&self) -> Option<&str>
pub fn custom_suggestion(&self) -> Option<&str>
Get the custom suggestion (if set)
Sourcepub fn suggestion(&self) -> Option<String>
pub fn suggestion(&self) -> Option<String>
Get the effective suggestion (custom or default)
Sourcepub fn build_context(&self) -> ErrorContext
pub fn build_context(&self) -> ErrorContext
Build an enriched error context
Trait Implementations§
Source§impl Debug for ErrorBuilder
impl Debug for ErrorBuilder
Source§impl From<ErrorBuilder> for OxiGdalError
Convert ErrorBuilder into OxiGdalError
impl From<ErrorBuilder> for OxiGdalError
Convert ErrorBuilder into OxiGdalError