Struct amethyst::ecs::common::Errors [−]
pub struct Errors { /* fields omitted */ }A resource you can use to store errors that occurred outside of the ECS but were catched inside, therefore should be handled by the user.
Methods
impl Errors
impl Errorspub fn new() -> Errors
pub fn new() -> ErrorsCreates a new instance of Errors.
pub fn add(&self, error: BoxedErr)
pub fn add(&self, error: BoxedErr)Add an error to the error collection.
pub fn execute<E, F>(&self, f: F) where
E: Error + Send + Sync + 'static,
F: FnOnce() -> Result<(), E>,
pub fn execute<E, F>(&self, f: F) where
E: Error + Send + Sync + 'static,
F: FnOnce() -> Result<(), E>, A convenience method which allows nicer error handling.
Examples
errors.execute::<Error, _>(|| { let y = do_something()?; println!("{}", y + 5); Ok(()) });
So the closure you pass to this method is essentially an environment where you can
use ? for error handling.
pub fn has_error(&self) -> bool
pub fn has_error(&self) -> boolChecks if the queue contains at least one error.
pub fn pop_err(&mut self) -> Option<BoxedErr>
pub fn pop_err(&mut self) -> Option<BoxedErr>Removes the first error from the queue.
ⓘImportant traits for DrainErrors<'a>pub fn drain(&mut self) -> DrainErrors
ⓘImportant traits for DrainErrors<'a>
pub fn drain(&mut self) -> DrainErrorsReturns a draining iterator, removing elements
on each call to Iterator::next.
pub fn collect(&mut self) -> Vec<BoxedErr>
pub fn collect(&mut self) -> Vec<BoxedErr>Collect all errors into a Vec.
pub fn print_and_exit(&mut self)
pub fn print_and_exit(&mut self)Prints all errors and exits in case there's been an error. Useful for debugging.