diff --git a/core/lib/src/error.rs b/core/lib/src/error.rs index 12bd961e..e9ed7696 100644 --- a/core/lib/src/error.rs +++ b/core/lib/src/error.rs @@ -51,17 +51,26 @@ pub enum LaunchErrorKind { /// as inspected; a subsequent `drop` of the value will _not_ result in a panic. /// The following snippet illustrates this: /// -// TODO.async This isn't true any more, as `.launch()` now returns a -// `Result<(), crate::error::Error>`, which could also be a runtime error. -/// ```rust,ignore +/// ```rust +/// use rocket::error::Error; +/// /// # if false { -/// let error = rocket::ignite().launch(); +/// if let Err(error) = rocket::ignite().launch() { +/// match error { +/// Error::Launch(error) => { +/// // This case is only reached if launching failed. This println "inspects" the error. +/// println!("Launch failed! Error: {}", error); /// -/// // 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); +/// } +/// Error::Run(error) => { +/// // This case is reached if launching succeeds, but the server had a fatal error later +/// println!("Server failed! Error: {}", error); +/// } +/// } +/// } /// -/// // This call to drop (explicit here for demonstration) will do nothing. -/// drop(error); /// # } /// ``` /// diff --git a/examples/errors/src/main.rs b/examples/errors/src/main.rs index 8cad7a21..8ad4bc35 100644 --- a/examples/errors/src/main.rs +++ b/examples/errors/src/main.rs @@ -19,13 +19,14 @@ fn not_found(req: &rocket::Request<'_>) -> content::Html { } fn main() { - let e = rocket::ignite() + let result = rocket::ignite() // .mount("/", routes![hello, hello]) // uncoment this to get an error .mount("/", routes![hello]) .register(catchers![not_found]) .launch(); - println!("Whoops! Rocket didn't launch!"); - // TODO.async Uncomment the following line once `.launch()`'s error type is determined. - // println!("This went wrong: {}", e); + if let Err(e) = result { + println!("Whoops! Rocket didn't launch!"); + println!("This went wrong: {:?}", e); + }; }