From 56b14454dc52f16f9c5a0f9d9bd21c12203da944 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Mon, 13 Jan 2025 15:43:20 +0530 Subject: [PATCH] Display context for `ruff.configuration` errors (#15452) ## Summary I noticed this while trying out https://github.com/astral-sh/ruff-vscode/issues/665 that we use the `Display` implementation to show the error which hides the context. This PR changes it to use the `Debug` implementation and adds the message as a context. ## Test Plan **Before:** ``` 0.001228084s ERROR main ruff_server::session::index::ruff_settings: Unable to find editor-specified configuration file: Failed to parse /private/tmp/hatch-test/ruff.toml ``` **After:** ``` 0.002348750s ERROR main ruff_server::session::index::ruff_settings: Unable to load editor-specified configuration file Caused by: 0: Failed to parse /private/tmp/hatch-test/ruff.toml 1: TOML parse error at line 2, column 18 | 2 | extend-select = ["ASYNC101"] | ^^^^^^^^^^ Unknown rule selector: `ASYNC101` ``` --- crates/ruff_server/src/session/index/ruff_settings.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/ruff_server/src/session/index/ruff_settings.rs b/crates/ruff_server/src/session/index/ruff_settings.rs index 9341595289..d092885c60 100644 --- a/crates/ruff_server/src/session/index/ruff_settings.rs +++ b/crates/ruff_server/src/session/index/ruff_settings.rs @@ -386,8 +386,12 @@ impl ConfigurationTransformer for EditorConfigurationTransformer<'_> { ); match open_configuration_file(&config_file_path) { Ok(config_from_file) => editor_configuration.combine(config_from_file), - Err(err) => { - tracing::error!("Unable to find editor-specified configuration file: {err}"); + err => { + tracing::error!( + "{:?}", + err.context("Unable to load editor-specified configuration file") + .unwrap_err() + ); editor_configuration } }