Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show full error context in server messages #13029

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions crates/ruff_server/src/session/index/ruff_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;

use anyhow::Context;
use ignore::{WalkBuilder, WalkState};

use ruff_linter::{
Expand Down Expand Up @@ -100,7 +101,7 @@ impl RuffSettings {

impl RuffSettingsIndex {
pub(super) fn new(root: &Path, editor_settings: &ResolvedEditorSettings) -> Self {
let mut error = false;
let mut has_error = false;
let mut index = BTreeMap::default();
let mut respect_gitignore = None;

Expand All @@ -127,20 +128,27 @@ impl RuffSettingsIndex {
);
break;
}
Err(err) => {
error => {
tracing::error!(
"Error while resolving settings from {}: {err}",
pyproject.display()
"{:#}",
error
.with_context(|| {
format!(
"Failed to resolve settings for {}",
pyproject.display()
)
})
.unwrap_err()
);
error = true;
has_error = true;
continue;
}
}
}
Ok(None) => continue,
Err(err) => {
tracing::error!("{err}");
error = true;
tracing::error!("{err:#}");
has_error = true;
continue;
}
}
Expand All @@ -162,7 +170,7 @@ impl RuffSettingsIndex {
let walker = builder.build_parallel();

let index = std::sync::RwLock::new(index);
let error = AtomicBool::new(error);
let has_error = AtomicBool::new(has_error);

walker.run(|| {
Box::new(|result| {
Expand Down Expand Up @@ -224,27 +232,34 @@ impl RuffSettingsIndex {
}),
);
}
Err(err) => {
error => {
tracing::error!(
"Error while resolving settings from {}: {err}",
pyproject.display()
"{:#}",
error
.with_context(|| {
format!(
"Failed to resolve settings for {}",
pyproject.display()
)
})
.unwrap_err()
);
error.store(true, Ordering::Relaxed);
has_error.store(true, Ordering::Relaxed);
}
}
}
Ok(None) => {}
Err(err) => {
tracing::error!("{err}");
error.store(true, Ordering::Relaxed);
tracing::error!("{err:#}");
has_error.store(true, Ordering::Relaxed);
}
}

WalkState::Continue
})
});

if error.load(Ordering::Relaxed) {
if has_error.load(Ordering::Relaxed) {
let root = root.display();
show_err_msg!(
"Error while resolving settings from workspace {root}. Please refer to the logs for more details.",
Expand Down
Loading