Simplify config loading by replacing match with unwrap_or_else for improved readability.

This commit is contained in:
Till Wegmueller 2025-12-08 22:49:35 +01:00
parent 81bc7b8574
commit ee02bf3cf0
No known key found for this signature in database

View file

@ -20,9 +20,7 @@ pub async fn run() -> Result<()> {
// For M1, let's just create a dummy default if not found/failed for testing purposes // For M1, let's just create a dummy default if not found/failed for testing purposes
// In a real scenario we'd want to be more specific about errors. // In a real scenario we'd want to be more specific about errors.
let config = match Config::load(args.config.clone()) { let config = Config::load(args.config.clone()).unwrap_or_else(|e| {
Ok(c) => c,
Err(e) => {
eprintln!("Failed to load config: {}. Using default.", e); eprintln!("Failed to load config: {}. Using default.", e);
Config { Config {
server: config::ServerConfig { server: config::ServerConfig {
@ -42,8 +40,7 @@ pub async fn run() -> Result<()> {
admin: None, admin: None,
oauth2: None, oauth2: None,
} }
} });
};
// Init telemetry // Init telemetry
telemetry::init(&config); telemetry::init(&config);