error handling for deserialize
This commit is contained in:
@@ -36,6 +36,13 @@ impl Settings {
|
|||||||
.prefix_separator("_"),
|
.prefix_separator("_"),
|
||||||
);
|
);
|
||||||
|
|
||||||
builder.build()?.try_deserialize()
|
let config = builder.build()?;
|
||||||
|
|
||||||
|
// Try to deserialize and provide error message
|
||||||
|
config.try_deserialize().map_err(|e| {
|
||||||
|
eprintln!("Configuration error: {}", e);
|
||||||
|
eprintln!("Required fields: server.url, app.heartbeat_interval_secs, app.metrics_interval_secs, app.port");
|
||||||
|
e
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user