pub trait StdError: Debug + Display {
fn source(&self) -> Option<&(dyn Error + 'static)> { ... }
fn backtrace(&self) -> Option<&Backtrace> { ... }
fn description(&self) -> &str { ... }
fn cause(&self) -> Option<&dyn Error> { ... }
}
Expand description
Error
is a trait representing the basic expectations for error values,
i.e., values of type E
in Result<T, E>
.
Errors must describe themselves through the Display
and Debug
traits. Error messages are typically concise lowercase sentences without
trailing punctuation:
let err = "NaN".parse::<u32>().unwrap_err();
assert_eq!(err.to_string(), "invalid digit found in string");
Errors may provide cause chain information. Error::source()
is generally
used when errors cross “abstraction boundaries”. If one module must report
an error that is caused by an error from a lower-level module, it can allow
accessing that error via Error::source()
. This makes it possible for the
high-level module to provide its own errors while also revealing some of the
implementation for debugging via source
chains.
Provided Methods
The lower-level source of this error, if any.
Examples
use std::error::Error;
use std::fmt;
#[derive(Debug)]
struct SuperError {
source: SuperErrorSideKick,
}
impl fmt::Display for SuperError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "SuperError is here!")
}
}
impl Error for SuperError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
Some(&self.source)
}
}
#[derive(Debug)]
struct SuperErrorSideKick;
impl fmt::Display for SuperErrorSideKick {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "SuperErrorSideKick is here!")
}
}
impl Error for SuperErrorSideKick {}
fn get_super_error() -> Result<(), SuperError> {
Err(SuperError { source: SuperErrorSideKick })
}
fn main() {
match get_super_error() {
Err(e) => {
println!("Error: {e}");
println!("Caused by: {}", e.source().unwrap());
}
_ => println!("No error"),
}
}
backtrace
)Returns a stack backtrace, if available, of where this error occurred.
This function allows inspecting the location, in code, of where an error
happened. The returned Backtrace
contains information about the stack
trace of the OS thread of execution of where the error originated from.
Note that not all errors contain a Backtrace
. Also note that a
Backtrace
may actually be empty. For more information consult the
Backtrace
type itself.
fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
if let Err(e) = "xc".parse::<u32>() {
// Print `e` itself, no need for description().
eprintln!("Error: {e}");
}
Implementations
sourceimpl dyn Error + 'static
impl dyn Error + 'static
1.3.0 · sourcepub fn is<T>(&self) -> bool where
T: 'static + Error,
pub fn is<T>(&self) -> bool where
T: 'static + Error,
Returns true
if the inner type is the same as T
.
1.3.0 · sourcepub fn downcast_ref<T>(&self) -> Option<&T> where
T: 'static + Error,
pub fn downcast_ref<T>(&self) -> Option<&T> where
T: 'static + Error,
Returns some reference to the inner value if it is of type T
, or
None
if it isn’t.
1.3.0 · sourcepub fn downcast_mut<T>(&mut self) -> Option<&mut T> where
T: 'static + Error,
pub fn downcast_mut<T>(&mut self) -> Option<&mut T> where
T: 'static + Error,
Returns some mutable reference to the inner value if it is of type T
, or
None
if it isn’t.
sourceimpl dyn Error + Send + 'static
impl dyn Error + Send + 'static
1.3.0 · sourcepub fn is<T>(&self) -> bool where
T: 'static + Error,
pub fn is<T>(&self) -> bool where
T: 'static + Error,
Forwards to the method defined on the type dyn Error
.
1.3.0 · sourcepub fn downcast_ref<T>(&self) -> Option<&T> where
T: 'static + Error,
pub fn downcast_ref<T>(&self) -> Option<&T> where
T: 'static + Error,
Forwards to the method defined on the type dyn Error
.
1.3.0 · sourcepub fn downcast_mut<T>(&mut self) -> Option<&mut T> where
T: 'static + Error,
pub fn downcast_mut<T>(&mut self) -> Option<&mut T> where
T: 'static + Error,
Forwards to the method defined on the type dyn Error
.
sourceimpl dyn Error + Send + Sync + 'static
impl dyn Error + Send + Sync + 'static
1.3.0 · sourcepub fn is<T>(&self) -> bool where
T: 'static + Error,
pub fn is<T>(&self) -> bool where
T: 'static + Error,
Forwards to the method defined on the type dyn Error
.
1.3.0 · sourcepub fn downcast_ref<T>(&self) -> Option<&T> where
T: 'static + Error,
pub fn downcast_ref<T>(&self) -> Option<&T> where
T: 'static + Error,
Forwards to the method defined on the type dyn Error
.
1.3.0 · sourcepub fn downcast_mut<T>(&mut self) -> Option<&mut T> where
T: 'static + Error,
pub fn downcast_mut<T>(&mut self) -> Option<&mut T> where
T: 'static + Error,
Forwards to the method defined on the type dyn Error
.
sourceimpl dyn Error + 'static
impl dyn Error + 'static
1.3.0 · sourcepub fn downcast<T>(
self: Box<dyn Error + 'static, Global>
) -> Result<Box<T, Global>, Box<dyn Error + 'static, Global>> where
T: 'static + Error,
pub fn downcast<T>(
self: Box<dyn Error + 'static, Global>
) -> Result<Box<T, Global>, Box<dyn Error + 'static, Global>> where
T: 'static + Error,
Attempts to downcast the box to a concrete type.
sourcepub fn chain(&self) -> Chain<'_>ⓘNotable traits for Chain<'a>impl<'a> Iterator for Chain<'a> type Item = &'a (dyn Error + 'static);
🔬 This is a nightly-only experimental API. (error_iter
)
pub fn chain(&self) -> Chain<'_>ⓘNotable traits for Chain<'a>impl<'a> Iterator for Chain<'a> type Item = &'a (dyn Error + 'static);
error_iter
)Returns an iterator starting with the current error and continuing with
recursively calling Error::source
.
If you want to omit the current error and only use its sources,
use skip(1)
.
Examples
#![feature(error_iter)]
use std::error::Error;
use std::fmt;
#[derive(Debug)]
struct A;
#[derive(Debug)]
struct B(Option<Box<dyn Error + 'static>>);
impl fmt::Display for A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "A")
}
}
impl fmt::Display for B {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "B")
}
}
impl Error for A {}
impl Error for B {
fn source(&self) -> Option<&(dyn Error + 'static)> {
self.0.as_ref().map(|e| e.as_ref())
}
}
let b = B(Some(Box::new(A)));
// let err : Box<Error> = b.into(); // or
let err = &b as &(dyn Error);
let mut iter = err.chain();
assert_eq!("B".to_string(), iter.next().unwrap().to_string());
assert_eq!("A".to_string(), iter.next().unwrap().to_string());
assert!(iter.next().is_none());
assert!(iter.next().is_none());
Trait Implementations
sourceimpl<'a, '_> From<&str> for Box<dyn Error + Send + Sync + 'a, Global>
impl<'a, '_> From<&str> for Box<dyn Error + Send + Sync + 'a, Global>
sourcefn from(err: &str) -> Box<dyn Error + Send + Sync + 'a, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn from(err: &str) -> Box<dyn Error + Send + Sync + 'a, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
1.6.0 · sourceimpl<'_> From<&str> for Box<dyn Error + 'static, Global>
impl<'_> From<&str> for Box<dyn Error + 'static, Global>
sourcefn from(err: &str) -> Box<dyn Error + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn from(err: &str) -> Box<dyn Error + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
1.22.0 · sourceimpl<'a> From<Cow<'a, str>> for Box<dyn Error + 'static, Global>
impl<'a> From<Cow<'a, str>> for Box<dyn Error + 'static, Global>
sourcefn from(err: Cow<'a, str>) -> Box<dyn Error + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn from(err: Cow<'a, str>) -> Box<dyn Error + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
1.22.0 · sourceimpl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a, Global>
impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a, Global>
sourcefn from(err: Cow<'b, str>) -> Box<dyn Error + Send + Sync + 'a, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn from(err: Cow<'b, str>) -> Box<dyn Error + Send + Sync + 'a, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Converts a Cow
into a box of dyn Error
+ Send
+ Sync
.
Examples
use std::error::Error;
use std::mem;
use std::borrow::Cow;
let a_cow_str_error = Cow::from("a str error");
let a_boxed_error = Box::<dyn Error + Send + Sync>::from(a_cow_str_error);
assert!(
mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
sourceimpl<'a, E> From<E> for Box<dyn Error + 'a, Global> where
E: 'a + Error,
impl<'a, E> From<E> for Box<dyn Error + 'a, Global> where
E: 'a + Error,
sourcefn from(err: E) -> Box<dyn Error + 'a, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn from(err: E) -> Box<dyn Error + 'a, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Converts a type of Error
into a box of dyn Error
.
Examples
use std::error::Error;
use std::fmt;
use std::mem;
#[derive(Debug)]
struct AnError;
impl fmt::Display for AnError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "An error")
}
}
impl Error for AnError {}
let an_error = AnError;
assert!(0 == mem::size_of_val(&an_error));
let a_boxed_error = Box::<dyn Error>::from(an_error);
assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
sourceimpl<'a, E> From<E> for Box<dyn Error + Send + Sync + 'a, Global> where
E: 'a + Error + Send + Sync,
impl<'a, E> From<E> for Box<dyn Error + Send + Sync + 'a, Global> where
E: 'a + Error + Send + Sync,
sourcefn from(err: E) -> Box<dyn Error + Send + Sync + 'a, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn from(err: E) -> Box<dyn Error + Send + Sync + 'a, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Converts a type of Error
+ Send
+ Sync
into a box of
dyn Error
+ Send
+ Sync
.
Examples
use std::error::Error;
use std::fmt;
use std::mem;
#[derive(Debug)]
struct AnError;
impl fmt::Display for AnError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "An error")
}
}
impl Error for AnError {}
unsafe impl Send for AnError {}
unsafe impl Sync for AnError {}
let an_error = AnError;
assert!(0 == mem::size_of_val(&an_error));
let a_boxed_error = Box::<dyn Error + Send + Sync>::from(an_error);
assert!(
mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
sourceimpl From<Error> for Box<dyn Error + Send + 'static, Global>
impl From<Error> for Box<dyn Error + Send + 'static, Global>
sourcefn from(error: Error) -> Box<dyn Error + Send + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn from(error: Error) -> Box<dyn Error + Send + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Converts to this type from the input type.
sourceimpl From<Error> for Box<dyn Error + Send + Sync + 'static, Global>
impl From<Error> for Box<dyn Error + Send + Sync + 'static, Global>
sourcefn from(error: Error) -> Box<dyn Error + Send + Sync + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn from(error: Error) -> Box<dyn Error + Send + Sync + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Converts to this type from the input type.
sourceimpl From<Error> for Box<dyn Error + 'static, Global>
impl From<Error> for Box<dyn Error + 'static, Global>
sourcefn from(error: Error) -> Box<dyn Error + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn from(error: Error) -> Box<dyn Error + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Converts to this type from the input type.
impl From<Error> for Box<dyn Error + Send + Sync + 'static, Global>
impl From<Error> for Box<dyn Error + Send + Sync + 'static, Global>
fn from(error: Error) -> Box<dyn Error + Send + Sync + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn from(error: Error) -> Box<dyn Error + Send + Sync + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Converts to this type from the input type.
impl From<Error> for Box<dyn Error + 'static, Global>
impl From<Error> for Box<dyn Error + 'static, Global>
fn from(error: Error) -> Box<dyn Error + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn from(error: Error) -> Box<dyn Error + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Converts to this type from the input type.
1.6.0 · sourceimpl From<String> for Box<dyn Error + 'static, Global>
impl From<String> for Box<dyn Error + 'static, Global>
sourcefn from(str_err: String) -> Box<dyn Error + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn from(str_err: String) -> Box<dyn Error + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
sourceimpl From<String> for Box<dyn Error + Send + Sync + 'static, Global>
impl From<String> for Box<dyn Error + Send + Sync + 'static, Global>
sourcefn from(err: String) -> Box<dyn Error + Send + Sync + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn from(err: String) -> Box<dyn Error + Send + Sync + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Converts a String
into a box of dyn Error
+ Send
+ Sync
.
Examples
use std::error::Error;
use std::mem;
let a_string_error = "a string error".to_string();
let a_boxed_error = Box::<dyn Error + Send + Sync>::from(a_string_error);
assert!(
mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
Implementors
impl Error for AccountsSaveError
impl Error for InvalidScopedName
impl Error for KeyError
impl Error for LoadError
impl Error for MgmtError
impl Error for ApiPieceOpError
impl Error for Fatal
impl Error for Inapplicable
impl Error for InternalError
impl Error for PieceOpErrorPartiallyProcessed
impl Error for Infallible
impl Error for ZipError
impl Error for RecvTimeoutError
impl Error for TryRecvError
impl Error for VersionError
impl Error for SVGProcessingError
impl Error for LibraryLoadError
impl Error for LibraryLoadMFIncompat
impl Error for SubstErrorKind
impl Error for SpecError
impl Error for SVGSizeError
impl Error for RoundingError
impl Error for PacketFrameReadError
impl Error for PacketFrameWriteError
impl Error for VarError
impl Error for FlexiLoggerError
impl Error for Errno
impl Error for BernoulliError
impl Error for WeightedError
impl Error for otter::prelude::rmp_serde::decode::Error
impl Error for otter::prelude::rmp_serde::encode::Error
impl Error for otter::prelude::toml::ser::Error
impl Error for otter::prelude::toml_de::Error
impl Error for Void
impl Error for LogicError
impl Error for RangeImpossible
impl Error for time::ParseError
impl Error for DecodeError
impl Error for bzip2::mem::Error
impl Error for ImageError
impl Error for image::flat::Error
impl Error for OpenSSHKeyError
impl Error for otter_support::slotmap_slot_idx::Error
impl Error for regex::error::Error
impl Error for strum::ParseError
impl Error for url::parser::ParseError
impl Error for xmlparser::error::Error
impl Error for StreamError
impl Error for !
impl Error for AuthKeysManipError
impl Error for AccountNotFound
impl Error for BadAssetUrlToken
impl Error for NotBundle
impl Error for GameBeingDestroyed
impl Error for InternalLogicError
impl Error for TokenDeliveryError
impl Error for UnsupportedColourSpec
impl Error for PlayerNotFound
impl Error for RecvError
impl Error for AccessError
impl Error for Unsupported
impl Error for SubstError
impl Error for InvalidAbbrevPresentationLayout
impl Error for FutureInstantOutOfRange
impl Error for AuthorisationError
impl Error for otter::prelude::chrono::ParseError
impl Error for InvalidBufferSize
impl Error for InvalidLength
impl Error for otter::prelude::digest::InvalidOutputSize
impl Error for MacError
impl Error for JoinPathsError
impl Error for otter::prelude::fmt::Error
impl Error for otter::prelude::io::Error
impl Error for WriterPanicked
impl Error for ParseLevelError
impl Error for SetLoggerError
impl Error for ClearEnvError
impl Error for ReadError
impl Error for otter::prelude::rand::Error
impl Error for InvalidFakeTime
impl Error for RngIsReal
impl Error for TimeIsReal
impl Error for FromFloatSecsError
impl Error for SystemTimeError
impl Error for otter::prelude::toml::de::Error
impl Error for DatetimeParseError
impl Error for CoordinateOverflow
impl Error for PosCFromIteratorError
impl Error for ParseBoolError
impl Error for otter::prelude::otter_base::imports::str::Utf8Error
impl Error for TryFromIntError
impl Error for Overflow
impl Error for otter::prelude::otter_base::zcoord::ParseError
impl Error for TotallyUnboundedRange
impl Error for otter::prelude::otter_base::crates::serde_json::Error
impl Error for otter::prelude::otter_base::crates::serde::de::value::Error
impl Error for TryReserveError
impl Error for FromVecWithNulError
impl Error for IntoStringError
impl Error for NulError
impl Error for alloc::string::FromUtf8Error
impl Error for FromUtf16Error
impl Error for LayoutError
impl Error for AllocError
impl Error for TryFromSliceError
impl Error for BorrowError
impl Error for BorrowMutError
impl Error for CharTryFromError
impl Error for ParseCharError
impl Error for DecodeUtf16Error
impl Error for TryFromCharError
impl Error for FromBytesUntilNulError
impl Error for FromBytesWithNulError
impl Error for ParseFloatError
impl Error for ParseIntError
impl Error for AddrParseError
impl Error for StripPrefixError
impl Error for ExitStatusError
impl Error for OutOfRangeError
impl Error for erased_serde::error::Error
impl Error for CompressError
impl Error for DecompressError
impl Error for getrandom::error::Error
impl Error for glob::GlobError
impl Error for PatternError
impl Error for image::error::DecodingError
impl Error for image::error::EncodingError
impl Error for LimitError
impl Error for ParameterError
impl Error for UnsupportedError
impl Error for ParseBigIntError
impl Error for ParseRatioError
impl Error for FloatIsNan
impl Error for Broken
impl Error for SenderError
impl Error for PathPersistError
impl Error for PersistError
impl Error for tera::errors::Error
impl Error for InvalidPassword
impl Error for BytesReadError
impl Error for CaseFoldError
impl Error for ComponentRange
impl Error for ConversionRange
impl Error for DecodingError
impl Error for DifferentVariant
impl Error for EncodingError
impl Error for Error
impl Error for Error
impl Error for Error
impl Error for Error
impl Error for Error
impl Error for Error
impl Error for Error
impl Error for Error
impl Error for Error
impl Error for Error
impl Error for Error
impl Error for Error
impl Error for Error
impl Error for Errors
impl Error for Format
impl Error for FromUtf8Error
impl Error for GlobError
impl Error for IndeterminateOffset
impl Error for InvalidFormatDescription
impl Error for InvalidOutputSize
impl Error for InvalidVariant
impl Error for NumValueReadError<Error>
impl Error for Parse
impl Error for ParseColorError
impl Error for ParseFromDescription
impl Error for TryFromParsed
impl Error for UnicodeWordError
impl Error for Utf8Error
impl Error for ValueReadError<Error>
impl<'a, E> Error for DecodeStringError<'a, E> where
E: RmpReadErr,
impl<'a, K, V> Error for otter::prelude::btree_map::OccupiedError<'a, K, V, Global> where
K: Debug + Ord,
V: Debug,
impl<'a, K, V> Error for otter::prelude::hash_map::OccupiedError<'a, K, V> where
K: Debug,
V: Debug,
impl<'a, T> Error for &'a T where
T: Error + ?Sized,
impl<'i, R> Error for pest::error::Error<R> where
R: RuleType,
impl<'p> Error for PieceTraitDowncastFailed<'p>
impl<E> Error for ParseNotNanError<E> where
E: 'static + Debug + Error,
impl<E> Error for Incompat<E> where
Self: Debug + Display,
impl<E> Error for ParseComplexError<E> where
E: Error,
impl<E> Error for Compat<E> where
E: Display + Debug,
impl<E> Error for ValueWriteError<E> where
E: RmpWriteErr,
impl<I> Error for ExactlyOneError<I> where
I: Iterator + Debug,
<I as Iterator>::Item: Debug,
impl<L, R> Error for Either<L, R> where
L: Error,
R: Error,
Either
implements Error
if both L
and R
implement it.
impl<T> Error for otter::imports::mpsc::TrySendError<T> where
T: Send,
impl<T> Error for TryLockError<T>
impl<T> Error for otter::imports::mpsc::SendError<T> where
T: Send,
impl<T> Error for Arc<T> where
T: Error + ?Sized,
impl<T> Error for CapacityError<T> where
T: Any,
Requires features="std"
.