#[non_exhaustive]pub enum Error {
Show 15 variants
NotFound {
kind: ObjectKind,
name: String,
available: Vec<String>,
},
AlreadyExists {
kind: ObjectKind,
name: String,
},
NameTaken {
kind: ObjectKind,
name: String,
},
InvalidName {
kind: ObjectKind,
name: String,
reason: String,
},
OutOfBounds {
what: &'static str,
index: usize,
len: usize,
},
InvalidRange(String),
EmptyWorkbook,
LastSheetInWorkbook,
DocumentModuleExists,
InvalidArgument(String),
Xlsx(String),
Vba(String),
VbaSyntax {
message: String,
module: Option<String>,
line: u32,
column: u32,
},
VbaRuntime {
message: String,
number: i32,
},
Eval(EngineError),
}Expand description
Errors returned by visi-core’s public API.
This enum is #[non_exhaustive]: match with a _ arm, since new variants
may be added in a minor release.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
NotFound
No object of this kind goes by this name (or id, for charts).
Fields
kind: ObjectKindWhat was being looked up.
AlreadyExists
An object of this kind already goes by this name, so it cannot be added.
NameTaken
A rename was rejected because the new name is already in use.
Distinct from Error::AlreadyExists, which is raised when creating.
InvalidName
A name was rejected as structurally invalid, independent of collisions.
Fields
kind: ObjectKindWhat was being named.
OutOfBounds
A row or column index fell outside the sheet.
Fields
InvalidRange(String)
A cell range was malformed – for example, an end before its start.
EmptyWorkbook
The operation needs at least one sheet and the workbook has none.
LastSheetInWorkbook
The last remaining sheet cannot be deleted; a workbook needs one.
DocumentModuleExists
A worksheet can carry only one bound VBA document module.
InvalidArgument(String)
The operation was rejected by a lower layer that does not yet report a typed error – currently the Excel Table and pivot internals.
Carries message text only. Do not match on the string; variants will be
carved out of this one as those layers are typed, which is why Error
is #[non_exhaustive].
Xlsx(String)
Reading or writing the .xlsx container failed.
Vba(String)
Reading or writing the VBA project failed.
VbaSyntax
A VBA module failed to parse.
Carries the position separately from the message so a caller can point
at the offending line – an editor integration, or visi macro check --json – without parsing the text back out.
Fields
VbaRuntime
A VBA procedure raised a run-time error.
Carries VBA’s own Err.Number so a caller can compare it against what
Excel would have raised, which is what the differential fuzzer does.
Eval(EngineError)
Formula evaluation failed.
Implementations§
Source§impl Error
impl Error
Sourcepub fn not_found(kind: ObjectKind, name: impl Into<String>) -> Self
pub fn not_found(kind: ObjectKind, name: impl Into<String>) -> Self
A Error::NotFound with no “did you mean” candidates.
Sourcepub fn not_found_among(
kind: ObjectKind,
name: impl Into<String>,
available: Vec<String>,
) -> Self
pub fn not_found_among( kind: ObjectKind, name: impl Into<String>, available: Vec<String>, ) -> Self
A Error::NotFound that also carries the names that do exist.
Trait Implementations§
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()