forked from mirrors/jj
config: wrap config errors in our own type
This commit is contained in:
parent
8289e87423
commit
8b54ac58bd
1 changed files with 8 additions and 1 deletions
|
@ -14,9 +14,16 @@
|
|||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use thiserror::Error;
|
||||
|
||||
use jujutsu_lib::settings::UserSettings;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ConfigError {
|
||||
#[error(transparent)]
|
||||
ConfigReadError(#[from] config::ConfigError),
|
||||
}
|
||||
|
||||
fn config_path() -> Option<PathBuf> {
|
||||
if let Ok(config_path) = env::var("JJ_CONFIG") {
|
||||
// TODO: We should probably support colon-separated (std::env::split_paths)
|
||||
|
@ -56,7 +63,7 @@ fn env_overrides() -> config::Config {
|
|||
builder.build().unwrap()
|
||||
}
|
||||
|
||||
pub fn read_config() -> Result<UserSettings, config::ConfigError> {
|
||||
pub fn read_config() -> Result<UserSettings, ConfigError> {
|
||||
let mut config_builder = config::Config::builder().add_source(env_base());
|
||||
|
||||
if let Some(config_path) = config_path() {
|
||||
|
|
Loading…
Reference in a new issue