pub struct ExcelError {
pub kind: ExcelErrorKind,
/* private fields */
}Expand description
The single struct your API passes around.
It combines:
- kind – the mandatory Excel error code
- message– optional human explanation
- context– generic location†
- extra – optional, kind-specific data
† If you never need row/col you can build the value with
ExcelError::from(kind), which sets context = None.
Fields§
§kind: ExcelErrorKindImplementations§
Source§impl ExcelError
impl ExcelError
Sourcepub fn from_function_panic(function: &str, payload: &(dyn Any + Send)) -> Self
pub fn from_function_panic(function: &str, payload: &(dyn Any + Send)) -> Self
Convert an unwinding Rust function panic to a typed #VALUE! error.
Sourcepub fn new(kind: ExcelErrorKind) -> Self
pub fn new(kind: ExcelErrorKind) -> Self
Basic constructor (no message, no location, no extra).
Sourcepub fn context(&self) -> Option<&ErrorContext>
pub fn context(&self) -> Option<&ErrorContext>
Generic location metadata, if supplied.
Sourcepub fn extra(&self) -> &ExcelErrorExtra
pub fn extra(&self) -> &ExcelErrorExtra
Kind-specific data; payload-free errors return ExcelErrorExtra::None.
Sourcepub fn set_message(&mut self, message: Option<String>)
pub fn set_message(&mut self, message: Option<String>)
Replace or clear the explanation, retaining any other metadata.
Sourcepub fn set_context(&mut self, context: Option<ErrorContext>)
pub fn set_context(&mut self, context: Option<ErrorContext>)
Replace or clear the location, retaining any other metadata.
Sourcepub fn set_extra(&mut self, extra: ExcelErrorExtra)
pub fn set_extra(&mut self, extra: ExcelErrorExtra)
Replace or clear the kind-specific data, retaining any other metadata.
Sourcepub fn with_message<S: Into<String>>(self, msg: S) -> Self
pub fn with_message<S: Into<String>>(self, msg: S) -> Self
Attach a human-readable explanation.
Sourcepub fn with_location(self, row: u32, col: u32) -> Self
pub fn with_location(self, row: u32, col: u32) -> Self
Attach generic row/column coordinates.
Sourcepub fn with_origin(self, sheet: Option<String>, row: u32, col: u32) -> Self
pub fn with_origin(self, sheet: Option<String>, row: u32, col: u32) -> Self
Attach origin location where the error first occurred.
Sourcepub fn with_extra(self, extra: ExcelErrorExtra) -> Self
pub fn with_extra(self, extra: ExcelErrorExtra) -> Self
Attach kind-specific extra data.
pub fn from_error_string(s: &str) -> Self
pub fn new_value() -> Self
pub fn new_name() -> Self
pub fn new_div() -> Self
pub fn new_ref() -> Self
pub fn new_circ() -> Self
pub fn new_num() -> Self
pub fn new_na() -> Self
Trait Implementations§
Source§impl Clone for ExcelError
impl Clone for ExcelError
Source§impl Debug for ExcelError
impl Debug for ExcelError
Source§impl Display for ExcelError
impl Display for ExcelError
impl Eq for ExcelError
Source§impl Error for ExcelError
impl Error for ExcelError
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()