Struct specs::common::Errors
[−]
[src]
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
[src]
pub fn new() -> Self
[src]
Creates a new instance of Errors
.
pub fn add(&self, error: BoxedErr)
[src]
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>,
[src]
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
[src]
Checks if the queue contains at least one error.
pub fn pop_err(&mut self) -> Option<BoxedErr>
[src]
Removes the first error from the queue.
ⓘImportant traits for DrainErrors<'a>pub fn drain(&mut self) -> DrainErrors
[src]
ⓘImportant traits for DrainErrors<'a>
Returns a draining iterator, removing elements
on each call to Iterator::next
.
pub fn collect(&mut self) -> Vec<BoxedErr>
[src]
Collect all errors into a Vec
.
pub fn print_and_exit(&mut self)
[src]
Prints all errors and exits in case there's been an error. Useful for debugging.
Trait Implementations
impl Debug for Errors
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more