[][src]Struct amethyst::Error

pub struct Error { /* fields omitted */ }

The error type used by Amethyst.

Wraps error diagnostics like messages and other errors, and keeps track of causal chains and backtraces.

Methods

impl Error
[src]

Default constructor for our error types.

Wraps anything that is an error in a box.

Update the source of an error.

Construct a new error from a string.

Get backtrace.

Get the source of the error.

Examples

The only way to set the source is through ResultExt using with_context.

use amethyst_error::{Error, ResultExt};
use std::io;

let e = io::Error::new(io::ErrorKind::Other, "wrapped");
let a = Error::new(e);

let res = Result::Err::<(), Error>(a).with_context(|_| Error::from_string("top"));
let e = res.expect_err("no error");

assert_eq!("top", e.to_string());
assert_eq!("wrapped", e.source().expect("no source").to_string());

Iterate over all causes, including this one.

Examples

use amethyst_error::{Error, ResultExt};

fn failing_function() -> Result<(), Error> {
    Err(Error::from_string("failing"))
}

fn other_function() -> Result<(), Error> {
    Ok(failing_function().with_context(|_| Error::from_string("other"))?)
}

let e = other_function().expect_err("no error");

let messages = e.causes().map(|e| e.to_string()).collect::<Vec<_>>();
assert_eq!(vec!["other", "failing"], messages);

Access the internal std::error::Error as a trait.

This can be useful for integrating with systems that operate on std::error::Error.

Warning: This erases most diagnostics in favor of returning only the top error. std::error::Error is expanded further.

Trait Implementations

impl<T> From<T> for Error where
    T: 'static + Error + Send + Sync
[src]

Blanket implementation.

Encapsulate errors which are Send + Sync.

impl Debug for Error
[src]

impl Display for Error
[src]

Auto Trait Implementations

impl Send for Error

impl Sync for Error

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Same for T

Should always be Self

impl<SS, SP> SupersetOf for SP where
    SS: SubsetOf<SP>, 

impl<T> Any for T where
    T: Any

impl<T> Resource for T where
    T: Any + Send + Sync

impl<T> Event for T where
    T: Send + Sync + 'static, 

impl<T> Erased for T

impl<T> Erased for T

impl<T> SetParameter for T

Sets value as a parameter of self.