Skip to content

Commit

Permalink
Better missing dotenv error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Coca162 committed Dec 19, 2022
1 parent 7953dc4 commit 7c243ae
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ async fn main() {
// Placed here so nobody forgets to add a new command to the command handler
let commands = vec![help(), pong()];

if matches!(dotenv(), Err(_)) && !not_using_dotenv() {
println!("You have not included a .env file! If this is intentional you can disable this warning with `DISABLE_NO_DOTENV_WARNING=1`")
}
if let Err(err) = dotenv() {
if err.not_found() && !not_using_dotenv() {
println!("You have not included a .env file! If this is intentional you can disable this warning with `DISABLE_NO_DOTENV_WARNING=1`")
} else {
panic!("Panicked on dotenv error: {}", err);
}
};

// Logging with configuration from environment variables via the `env-filter` feature
tracing_subscriber::fmt::init();
Expand Down

0 comments on commit 7c243ae

Please sign in to comment.