File tree 2 files changed +22
-12
lines changed
2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -51,17 +51,26 @@ pub enum LaunchErrorKind {
51
51
/// as inspected; a subsequent `drop` of the value will _not_ result in a panic.
52
52
/// The following snippet illustrates this:
53
53
///
54
- // TODO.async This isn't true any more, as `.launch()` now returns a
55
- // `Result<(), crate ::error::Error>`, which could also be a runtime error.
56
- /// ```rust,ignore
54
+ /// ```rust
55
+ /// use rocket ::error::Error;
56
+ ///
57
57
/// # if false {
58
- /// let error = rocket::ignite().launch();
58
+ /// if let Err(error) = rocket::ignite().launch() {
59
+ /// match error {
60
+ /// Error::Launch(error) => {
61
+ /// // This case is only reached if launching failed. This println "inspects" the error.
62
+ /// println!("Launch failed! Error: {}", error);
59
63
///
60
- /// // This line is only reached if launching failed. This "inspects" the error.
61
- /// println!("Launch failed! Error: {}", error);
64
+ /// // This call to drop (explicit here for demonstration) will do nothing.
65
+ /// drop(error);
66
+ /// }
67
+ /// Error::Run(error) => {
68
+ /// // This case is reached if launching succeeds, but the server had a fatal error later
69
+ /// println!("Server failed! Error: {}", error);
70
+ /// }
71
+ /// }
72
+ /// }
62
73
///
63
- /// // This call to drop (explicit here for demonstration) will do nothing.
64
- /// drop(error);
65
74
/// # }
66
75
/// ```
67
76
///
Original file line number Diff line number Diff line change @@ -19,13 +19,14 @@ fn not_found(req: &rocket::Request<'_>) -> content::Html<String> {
19
19
}
20
20
21
21
fn main ( ) {
22
- let e = rocket:: ignite ( )
22
+ let result = rocket:: ignite ( )
23
23
// .mount("/", routes![hello, hello]) // uncoment this to get an error
24
24
. mount ( "/" , routes ! [ hello] )
25
25
. register ( catchers ! [ not_found] )
26
26
. launch ( ) ;
27
27
28
- println ! ( "Whoops! Rocket didn't launch!" ) ;
29
- // TODO.async Uncomment the following line once `.launch()`'s error type is determined.
30
- // println!("This went wrong: {}", e);
28
+ if let Err ( e) = result {
29
+ println ! ( "Whoops! Rocket didn't launch!" ) ;
30
+ println ! ( "This went wrong: {:?}" , e) ;
31
+ } ;
31
32
}
You can’t perform that action at this time.
0 commit comments