Struct rocket::error::LaunchError
source · [−]pub struct LaunchError { /* private fields */ }
Expand description
An error that occurs during launch.
A LaunchError
is returned by launch()
when
launching an application fails.
Panics
A value of this type panics if it is dropped without first being inspected.
An inspection occurs when any method is called. For instance, if
println!("Error: {}", e)
is called, where e: LaunchError
, the
Display::fmt
method being called by println!
results in e
being marked
as inspected; a subsequent drop
of the value will not result in a panic.
The following snippet illustrates this:
let error = rocket::ignite().launch();
// This line is only reached if launching failed. This "inspects" the error.
println!("Launch failed! Error: {}", error);
// This call to drop (explicit here for demonstration) will do nothing.
drop(error);
When a value of this type panics, the corresponding error message is pretty printed to the console. The following illustrates this:
let error = rocket::ignite().launch();
// This call to drop (explicit here for demonstration) will result in
// `error` being pretty-printed to the console along with a `panic!`.
drop(error);
Usage
A LaunchError
value should usually be allowed to drop
without
inspection. There are two exceptions to this suggestion.
-
If you are writing a library or high-level application on-top of Rocket, you likely want to inspect the value before it drops to avoid a Rocket-specific
panic!
. This typically means simply printing the value. -
You want to display your own error messages.
Implementations
sourceimpl LaunchError
impl LaunchError
sourcepub fn kind(&self) -> &LaunchErrorKind
pub fn kind(&self) -> &LaunchErrorKind
Retrieve the kind
of the launch error.
Example
let error = rocket::ignite().launch();
// This line is only reached if launch failed.
let error_kind = error.kind();
Trait Implementations
sourceimpl Debug for LaunchError
impl Debug for LaunchError
sourceimpl Display for LaunchError
impl Display for LaunchError
sourceimpl Drop for LaunchError
impl Drop for LaunchError
sourceimpl Error for LaunchError
impl Error for LaunchError
sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
1.30.0 · sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
sourceimpl From<Error> for LaunchError
impl From<Error> for LaunchError
sourcefn from(error: Error) -> LaunchError
fn from(error: Error) -> LaunchError
Converts to this type from the input type.
sourceimpl From<Error> for LaunchError
impl From<Error> for LaunchError
sourcefn from(error: Error) -> LaunchError
fn from(error: Error) -> LaunchError
Converts to this type from the input type.
Auto Trait Implementations
impl !RefUnwindSafe for LaunchError
impl Send for LaunchError
impl Sync for LaunchError
impl Unpin for LaunchError
impl !UnwindSafe for LaunchError
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
sourcefn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
Converts self
into a collection.