main: Add better config/init error messages

The default messages printed when the process panics because the
configuration could not be loaded or the application context could not
be initialized are somewhat difficult to read.  Instead of calling
`unwrap` in these cases, we need to explicitly handle the errors and
print more appropriate messages.
This commit is contained in:
2025-04-05 06:55:57 -05:00
parent df560b18f2
commit a1308507af

View File

@@ -78,8 +78,20 @@ async fn rocket() -> _ {
let rocket = rocket::build();
let config: Config = rocket.figment().extract().unwrap();
let ctx = Context::init(config).unwrap();
let config: Config = match rocket.figment().extract() {
Ok(c) => c,
Err(e) => {
error!("Could not load configuration: {}", e);
std::process::exit(1);
},
};
let ctx = match Context::init(config) {
Ok(c) => c,
Err(e) => {
error!("Could not initialize application context: {}", e);
std::process::exit(1);
},
};
rocket
.manage(ctx)