wip: replace dyn Error with concrete
This commit is contained in:
11
src/init.rs
11
src/init.rs
@@ -3,12 +3,14 @@ mod config;
|
||||
pub(crate) mod error;
|
||||
|
||||
use std::env;
|
||||
use std::error as std_err;
|
||||
use anyhow::Context;
|
||||
|
||||
pub async fn start() -> Result<(), Box<dyn std_err::Error>> {
|
||||
const WINGMATE_CONFIG_PATH: &'static str = "WINGMATE_CONFIG_PATH";
|
||||
|
||||
pub async fn start() -> Result<(), error::WingmateInitError> {
|
||||
let mut vec_search: Vec<String> = Vec::new();
|
||||
|
||||
match env::var("WINGMATE_CONFIG_PATH") {
|
||||
match env::var(WINGMATE_CONFIG_PATH) {
|
||||
Ok(paths) => {
|
||||
for p in paths.split(':') {
|
||||
vec_search.push(String::from(p));
|
||||
@@ -16,7 +18,8 @@ pub async fn start() -> Result<(), Box<dyn std_err::Error>> {
|
||||
},
|
||||
Err(e) => {
|
||||
if let env::VarError::NotUnicode(_) = e {
|
||||
return Err(e.into());
|
||||
return Err(e).context(format!("reading {} env var", WINGMATE_CONFIG_PATH))
|
||||
.map_err(|e| {error::WingmateInitError::Other { source: e }} );
|
||||
} else {
|
||||
vec_search.push(String::from("/etc/wingmate"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user