Skip to content

Commit

Permalink
chore(common): improve error message when config.toml is missing (#1768)
Browse files Browse the repository at this point in the history
* chore(common): improve error message when config.toml is missing

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
wsxiaoys and autofix-ci[bot] authored Apr 5, 2024
1 parent 837e36d commit b46c50b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/tabby-common/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{collections::HashSet, path::PathBuf};

use anyhow::{anyhow, Result};
use anyhow::{anyhow, Context, Result};
use async_trait::async_trait;
use lazy_static::lazy_static;
use regex::Regex;
Expand All @@ -22,7 +22,11 @@ pub struct Config {

impl Config {
pub fn load() -> Result<Self> {
let mut cfg: Self = serdeconv::from_toml_file(crate::path::config_file().as_path())?;
let cfg_path = crate::path::config_file();
let mut cfg: Self = serdeconv::from_toml_file(cfg_path.as_path()).context(format!(
"Config file '{}' is missing or not valid",
cfg_path.display()
))?;

if let Err(e) = cfg.validate_names() {
cfg = Default::default();
Expand Down

0 comments on commit b46c50b

Please sign in to comment.