don't ignore dotenv errors (#630)

This commit is contained in:
fdb-hiroshima 2019-07-03 09:30:44 +02:00 committed by GitHub
parent 7ea4acc289
commit 5289fe872a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -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));

View file

@ -73,7 +73,11 @@ compile_i18n!();
/// Initializes a database pool.
fn init_pool() -> Option<DbPool> {
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::<Connection>::new(CONFIG.database_url.as_str());
let pool = DbPool::builder()