[−][src]Struct simple_error::SimpleError
A type that represents a simple error.
This type uses a String
to store the error string, and it implements std::error::Error
.
Methods
impl SimpleError
[src]
pub fn new<T: Into<String>>(t: T) -> SimpleError
[src]
Creates a new simple error.
This function can take any type that implements Into<String>
.
Examples
use self::simple_error::SimpleError; // errors can be created from `str` let err = SimpleError::new("an error from str"); // errors can also be created from `String` let err = SimpleError::new(String::from("an error from String"));
pub fn from<T: Error>(t: T) -> SimpleError
[src]
Creates a new simple error from another error.
This function can take any type that implements std::error::Error
.
The error string will be the Display
of the std::error::Error
.
Examples
use self::simple_error::SimpleError; use std::io; // errors can be created from `io::Error` let err = SimpleError::from(io::Error::new(io::ErrorKind::Other, "oh no")); assert_eq!("oh no", format!("{}", err));
pub fn with<T: Error>(s: &str, t: T) -> SimpleError
[src]
Creates a new simple error from a string with another error.
This function takes a string as error and a type that implements std::error::Error
as
reason.
The error string will be the Display
of the std::error::Error
prefixed with the string
and ", ".
Examples
use self::simple_error::SimpleError; let err = SimpleError::with("cannot turn on tv", SimpleError::new("remote not found")); assert_eq!("cannot turn on tv, remote not found", format!("{}", err));
pub fn as_str(&self) -> &str
[src]
Extracts a string slice describing the error.
Examples
use self::simple_error::SimpleError; let s = SimpleError::new("critical error"); assert_eq!("critical error", s.as_str());
Trait Implementations
impl PartialEq<SimpleError> for SimpleError
[src]
fn eq(&self, other: &SimpleError) -> bool
[src]
fn ne(&self, other: &SimpleError) -> bool
[src]
impl Eq for SimpleError
[src]
impl<'a> From<&'a str> for SimpleError
[src]
fn from(s: &str) -> SimpleError
[src]
impl Clone for SimpleError
[src]
fn clone(&self) -> SimpleError
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for SimpleError
[src]
impl Display for SimpleError
[src]
impl Error for SimpleError
[src]
fn description(&self) -> &str
[src]
fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
replaced by Error::source, which can support downcasting
The lower-level cause of this error, if any. Read more
fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]
The lower-level source of this error, if any. Read more
Auto Trait Implementations
impl Send for SimpleError
impl Unpin for SimpleError
impl Sync for SimpleError
impl UnwindSafe for SimpleError
impl RefUnwindSafe for SimpleError
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,