Skip to content
This repository was archived by the owner on Mar 24, 2024. It is now read-only.

Commit 6e16d8e

Browse files
committed
make settings return result instead of panicking
1 parent fa5f6df commit 6e16d8e

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mod bot;
2525
/// Entrypoint function to initialize other modules.
2626
#[tokio::main]
2727
async fn main() -> Result<()> {
28-
settings::init();
28+
settings::init()?;
2929

3030
logging::init()?;
3131

src/settings.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::{
1414
io::ErrorKind,
1515
};
1616

17+
use anyhow::{bail, Result};
1718
use config::{
1819
builder::DefaultState, ConfigBuilder, ConfigError, Environment, File,
1920
FileFormat,
@@ -382,13 +383,14 @@ pub(crate) fn settings() -> &'static Settings {
382383
}
383384

384385
/// Initialize the bot's [`Settings`].
385-
pub(crate) fn init() {
386+
pub(crate) fn init() -> Result<()> {
386387
match Settings::new() {
387388
Ok(settings) => {
388389
let _ = SETTINGS.set(settings);
390+
Ok(())
389391
}
390392
Err(e) => {
391-
panic!("Failed to parse settings: {}", e);
393+
bail!("Failed to parse settings: {}", e);
392394
}
393395
}
394396
}

0 commit comments

Comments
 (0)