Introducing env catcher function
This commit is contained in:
parent
8df494c949
commit
10498b9b57
15
src/environment.rs
Normal file
15
src/environment.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
//! Utility function to deal wit environment variable
|
||||
|
||||
use log::error;
|
||||
use std::env;
|
||||
|
||||
/// Get the environment variiable var_name or panic
|
||||
pub fn get_env_variable(var_name: &String) -> String {
|
||||
match env::var(var_name) {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
error!(target: "bot_warn_errors", "Failed to fetch the {} environment variable.", var_name);
|
||||
panic!("Exiting...");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
mod client;
|
||||
mod database;
|
||||
mod environment;
|
||||
pub mod errors;
|
||||
|
||||
pub use crate::{
|
||||
|
|
Loading…
Reference in a new issue