Better handle .env file loading error

Previously it would crash if the file did not exist
This commit is contained in:
Quentin Gliech
2021-08-26 11:14:49 +02:00
parent bf988180ae
commit be5fd8e271

View File

@@ -35,7 +35,12 @@ use self::cli::RootCommand;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Load environment variables from .env files
dotenv::dotenv()?;
if let Err(e) = dotenv::dotenv() {
// Display the error if it is something other than the .env file not existing
if !e.not_found() {
return Err(e).context("could not load .env file");
}
}
// Setup logging & tracing
let fmt_layer = tracing_subscriber::fmt::layer();