vw_small

Hardened fork of Vaultwarden (https://github.com/dani-garcia/vaultwarden) with fewer features.
git clone https://git.philomathiclife.com/repos/vw_small
Log | Files | Refs | README

commit 0dc0decaa712ed69f37c526e210492cbbc9577fa
parent e25fc7083de6703af23f576c5d469600c7036254
Author: Daniel GarcĂ­a <dani-garcia@users.noreply.github.com>
Date:   Sat, 14 Nov 2020 14:11:56 +0100

Merge pull request #1212 from BlackDex/dotenv-warnings

Added error handling during dotenv loading
Diffstat:
Msrc/config.rs | 27++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/config.rs b/src/config.rs @@ -53,7 +53,32 @@ macro_rules! make_config { impl ConfigBuilder { fn from_env() -> Self { - dotenv::from_path(".env").ok(); + match dotenv::from_path(".env") { + Ok(_) => (), + Err(e) => match e { + dotenv::Error::LineParse(msg, pos) => { + panic!("Error loading the .env file:\nNear {:?} on position {}\nPlease fix and restart!\n", msg, pos); + }, + dotenv::Error::Io(ioerr) => match ioerr.kind() { + std::io::ErrorKind::NotFound => { + println!("[INFO] No .env file found.\n"); + () + }, + std::io::ErrorKind::PermissionDenied => { + println!("[WARNING] Permission Denied while trying to read the .env file!\n"); + () + }, + _ => { + println!("[WARNING] Reading the .env file failed:\n{:?}\n", ioerr); + () + } + }, + _ => { + println!("[WARNING] Reading the .env file failed:\n{:?}\n", e); + () + } + } + }; let mut builder = ConfigBuilder::default(); $($(