mirror of https://github.com/rwf2/Rocket.git
Fix some launch error handling in tests and examples.
This commit is contained in:
parent
a0d2651e38
commit
77a64c73bb
|
@ -51,17 +51,26 @@ pub enum LaunchErrorKind {
|
||||||
/// as inspected; a subsequent `drop` of the value will _not_ result in a panic.
|
/// as inspected; a subsequent `drop` of the value will _not_ result in a panic.
|
||||||
/// The following snippet illustrates this:
|
/// The following snippet illustrates this:
|
||||||
///
|
///
|
||||||
// TODO.async This isn't true any more, as `.launch()` now returns a
|
/// ```rust
|
||||||
// `Result<(), crate::error::Error>`, which could also be a runtime error.
|
/// use rocket::error::Error;
|
||||||
/// ```rust,ignore
|
|
||||||
/// # if false {
|
|
||||||
/// let error = rocket::ignite().launch();
|
|
||||||
///
|
///
|
||||||
/// // This line is only reached if launching failed. This "inspects" the error.
|
/// # if false {
|
||||||
|
/// 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);
|
/// println!("Launch failed! Error: {}", error);
|
||||||
///
|
///
|
||||||
/// // This call to drop (explicit here for demonstration) will do nothing.
|
/// // This call to drop (explicit here for demonstration) will do nothing.
|
||||||
/// drop(error);
|
/// 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);
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
///
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
|
@ -19,13 +19,14 @@ fn not_found(req: &rocket::Request<'_>) -> content::Html<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let e = rocket::ignite()
|
let result = rocket::ignite()
|
||||||
// .mount("/", routes![hello, hello]) // uncoment this to get an error
|
// .mount("/", routes![hello, hello]) // uncoment this to get an error
|
||||||
.mount("/", routes![hello])
|
.mount("/", routes![hello])
|
||||||
.register(catchers![not_found])
|
.register(catchers![not_found])
|
||||||
.launch();
|
.launch();
|
||||||
|
|
||||||
|
if let Err(e) = result {
|
||||||
println!("Whoops! Rocket didn't 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);
|
||||||
// println!("This went wrong: {}", e);
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue