Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-16 04:12:53 +01:00
Merge pull request #1212 from BlackDex/dotenv-warnings
Added error handling during dotenv loading
Dieser Commit ist enthalten in:
Commit
0dc0decaa7
1 geänderte Dateien mit 26 neuen und 1 gelöschten Zeilen
|
@ -53,7 +53,32 @@ macro_rules! make_config {
|
||||||
|
|
||||||
impl ConfigBuilder {
|
impl ConfigBuilder {
|
||||||
fn from_env() -> Self {
|
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();
|
let mut builder = ConfigBuilder::default();
|
||||||
$($(
|
$($(
|
||||||
|
|
Laden …
In neuem Issue referenzieren