aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2024-05-23 16:16:34 +0200
committerJosh Rahm <rahm@google.com>2024-08-14 15:42:41 -0600
commitef8ce1ecaf0746ec9186beee010a86cae4c9338a (patch)
treea664d7d31102191a9ba1c62d27f409d393d4a5cc
parenta45adac92c447649a1123557e72939cf43233c99 (diff)
downloadr-alacritty-ef8ce1ecaf0746ec9186beee010a86cae4c9338a.tar.gz
r-alacritty-ef8ce1ecaf0746ec9186beee010a86cae4c9338a.tar.bz2
r-alacritty-ef8ce1ecaf0746ec9186beee010a86cae4c9338a.zip
Fix error with missing imports
This fixes a regression, likely introduced in 5d173f6df, which changed the severity of missing imports from `info` back to `error`. The cause of this issue was a more complicated error handling mechanism, which explicitly translated IO errors to a separate enum variant without accounting for it in all scenarios. While retrospectively this seems completely unnecessary to me, it did mean shorter error messages in case the main config file was not found. To preserve the benefits of both approaches, explicit handling for the `NotFound` IO error has been added when loading the main configuration file.
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty/src/config/mod.rs15
2 files changed, 6 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0c6aafe3..91536648 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,7 @@ Notable changes to the `alacritty_terminal` crate are documented in its
- While terminal in mouse mode, mouse bindings that used the shift modifier and
had multiple actions only performed the first action
- Leaking FDs when closing windows on Unix systems
+- Config emitting errors for non-existent import paths
## 0.13.2
diff --git a/alacritty/src/config/mod.rs b/alacritty/src/config/mod.rs
index 4ae3b67d..f043d73b 100644
--- a/alacritty/src/config/mod.rs
+++ b/alacritty/src/config/mod.rs
@@ -44,9 +44,6 @@ pub type Result<T> = std::result::Result<T, Error>;
/// Errors occurring during config loading.
#[derive(Debug)]
pub enum Error {
- /// Config file not found.
- NotFound,
-
/// Couldn't read $HOME environment variable.
ReadingEnvHome(env::VarError),
@@ -66,7 +63,6 @@ pub enum Error {
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
- Error::NotFound => None,
Error::ReadingEnvHome(err) => err.source(),
Error::Io(err) => err.source(),
Error::Toml(err) => err.source(),
@@ -79,7 +75,6 @@ impl std::error::Error for Error {
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
- Error::NotFound => write!(f, "Unable to locate config file"),
Error::ReadingEnvHome(err) => {
write!(f, "Unable to read $HOME environment variable: {}", err)
},
@@ -99,11 +94,7 @@ impl From<env::VarError> for Error {
impl From<io::Error> for Error {
fn from(val: io::Error) -> Self {
- if val.kind() == io::ErrorKind::NotFound {
- Error::NotFound
- } else {
- Error::Io(val)
- }
+ Error::Io(val)
}
}
@@ -179,6 +170,10 @@ fn after_loading(config: &mut UiConfig, options: &mut Options) {
fn load_from(path: &Path) -> Result<UiConfig> {
match read_config(path) {
Ok(config) => Ok(config),
+ Err(Error::Io(io)) if io.kind() == io::ErrorKind::NotFound => {
+ error!(target: LOG_TARGET_CONFIG, "Unable to load config {:?}: File not found", path);
+ Err(Error::Io(io))
+ },
Err(err) => {
error!(target: LOG_TARGET_CONFIG, "Unable to load config {:?}: {}", path, err);
Err(err)