pub struct StimError { /* private fields */ }Expand description
An error produced by the Stim library.
This is the unified error type for all fallible operations in the stim
crate. It wraps a human-readable message string describing what went wrong.
Most functions and methods in this crate return Result<T>,
which is an alias for std::result::Result<T, StimError>. When an operation
fails – for example because a circuit contains an invalid gate name, a
target index is out of range, a file cannot be read, or a stabilizer
operation is mathematically invalid – the error message explains the cause.
StimError implements the standard Error trait, so it
integrates smoothly with the Rust error-handling ecosystem (including
anyhow, eyre, and the ? operator). It also converts automatically
from C++ exceptions raised by the underlying Stim C++ library via the
From<cxx::Exception> implementation.
§Examples
let err = stim::StimError::new("invalid circuit syntax");
assert_eq!(err.message(), "invalid circuit syntax");
assert_eq!(err.to_string(), "invalid circuit syntax");
// StimError implements std::error::Error.
let dyn_err: Box<dyn std::error::Error> = Box::new(err);
assert_eq!(dyn_err.to_string(), "invalid circuit syntax");Implementations§
Trait Implementations§
Source§impl Error for StimError
impl Error for StimError
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()