pub struct Errors { /* private fields */ }
Expand description
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.
Implementations
sourceimpl Errors
impl Errors
sourcepub 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.
sourcepub fn drain(&mut self) -> DrainErrors<'_>ⓘNotable traits for DrainErrors<'a>impl<'a> Iterator for DrainErrors<'a> type Item = BoxedErr;
pub fn drain(&mut self) -> DrainErrors<'_>ⓘNotable traits for DrainErrors<'a>impl<'a> Iterator for DrainErrors<'a> type Item = BoxedErr;
Returns a draining iterator, removing elements
on each call to Iterator::next
.
sourcepub 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.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Errors
impl Send for Errors
impl Sync for Errors
impl Unpin for Errors
impl !UnwindSafe for Errors
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
sourcefn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
Tries to create the default.
sourcefn unwrap_default() -> Self
fn unwrap_default() -> Self
Calls
try_default
and panics on an error case.