Struct amethyst::Error [−]
The error type used by Amethyst.
Wraps error diagnostics like messages and other errors, and keeps track of causal chains and backtraces.
Implementations
impl Error
pub fn new<E>(error: E) -> Error where
E: 'static + Error + Send + Sync,
E: 'static + Error + Send + Sync,
Default constructor for our error types.
Wraps anything that is an error in a box.
pub fn with_source<S>(self, source: S) -> Error where
S: 'static + Into<Error>,
S: 'static + Into<Error>,
Update the source of an error.
pub fn from_string<M>(message: M) -> Error where
M: Into<Cow<'static, str>>,
M: Into<Cow<'static, str>>,
Construct a new error from a string.
pub fn backtrace(&self) -> Option<&Backtrace>
Get backtrace.
pub fn source(&self) -> Option<&Error>
Get the source of the error.
Examples
The source can be set using with_source
or
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());
pub fn causes(&self) -> Causes<'_>
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);
pub fn as_error(&self) -> &(dyn Error + 'static)
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 Debug for Error
impl Display for Error
impl<T> From<T> for Error where
T: 'static + Error + Send + Sync,
T: 'static + Error + Send + Sync,
Blanket implementation.
Encapsulate errors which are Send + Sync.
Auto Trait Implementations
impl !RefUnwindSafe for Error
[src]
impl Send for Error
[src]
impl Sync for Error
[src]
impl Unpin for Error
[src]
impl !UnwindSafe for Error
[src]
Blanket Implementations
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
T: Component + Float,
D: AdaptFrom<S, Swp, Dwp, T>,
Swp: WhitePoint,
Dwp: WhitePoint,
[src]
T: Component + Float,
D: AdaptFrom<S, Swp, Dwp, T>,
Swp: WhitePoint,
Dwp: WhitePoint,
pub fn adapt_into_using<M>(self, method: M) -> D where
M: TransformMatrix<Swp, Dwp, T>,
[src]
M: TransformMatrix<Swp, Dwp, T>,
pub fn adapt_into(self) -> D
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
pub fn get_type_id(&self) -> TypeId
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Event for T where
T: Send + Sync + 'static,
T: Send + Sync + 'static,
impl<T> From<!> for 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> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Resource for T where
T: Any + Send + Sync,
T: Any + Send + Sync,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> SetParameter for T
pub fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn is_in_subset(&self) -> bool
pub unsafe fn to_subset_unchecked(&self) -> SS
pub fn from_subset(element: &SS) -> SP
impl<T> Supports<T> for T
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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.
pub 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.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,