Skip to content

Commit d101974

Browse files
committed
worker - main - Environment::default() if ENV is not passed
1 parent 96f1ac5 commit d101974

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

validator_worker/src/main.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![deny(rust_2018_idioms)]
22
#![deny(clippy::all)]
33

4-
use std::error::Error;
4+
use std::{env::VarError, error::Error};
55

66
use clap::{crate_version, Arg, Command};
77

@@ -64,10 +64,12 @@ fn main() -> Result<(), Box<dyn Error>> {
6464
)
6565
.get_matches();
6666

67-
let environment: Environment = serde_json::from_value(serde_json::Value::String(
68-
std::env::var("ENV").expect("Valid environment variable"),
69-
))
70-
.expect("Valid Environment - development or production");
67+
let environment: Environment = match std::env::var("ENV") {
68+
Ok(string) => serde_json::from_value(serde_json::Value::String(string))
69+
.expect("Valid Environment - development or production"),
70+
Err(VarError::NotPresent) => Environment::default(),
71+
Err(err) => panic!("Invalid `ENV`: {err}"),
72+
};
7173

7274
let config_file = cli.value_of("config");
7375
let config = configuration(environment, config_file).expect("failed to parse configuration");

0 commit comments

Comments
 (0)