From 5289fe872ae4d2d3a5b6b6cc467b6750ca914d05 Mon Sep 17 00:00:00 2001 From: fdb-hiroshima <35889323+fdb-hiroshima@users.noreply.github.com> Date: Wed, 3 Jul 2019 09:30:44 +0200 Subject: [PATCH] don't ignore dotenv errors (#630) --- plume-cli/src/main.rs | 6 +++++- src/main.rs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/plume-cli/src/main.rs b/plume-cli/src/main.rs index cc4b85d7..a6d1b7db 100644 --- a/plume-cli/src/main.rs +++ b/plume-cli/src/main.rs @@ -25,7 +25,11 @@ fn main() { .subcommand(users::command()); let matches = app.clone().get_matches(); - dotenv::dotenv().ok(); + match dotenv::dotenv() { + Ok(path) => println!("Configuration read from {}", path.display()), + Err(ref e) if e.not_found() => eprintln!("no .env was found"), + e => e.map(|_| ()).unwrap(), + } let conn = Conn::establish(CONFIG.database_url.as_str()); let _ = conn.as_ref().map(|conn| Instance::cache_local(conn)); diff --git a/src/main.rs b/src/main.rs index 136f6a63..7701917e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,7 +73,11 @@ compile_i18n!(); /// Initializes a database pool. fn init_pool() -> Option { - dotenv::dotenv().ok(); + match dotenv::dotenv() { + Ok(path) => println!("Configuration read from {}", path.display()), + Err(ref e) if e.not_found() => eprintln!("no .env was found"), + e => e.map(|_| ()).unwrap(), + } let manager = ConnectionManager::::new(CONFIG.database_url.as_str()); let pool = DbPool::builder()