Skip to content

Conversation

@oscarvarto
Copy link
Contributor

Release Notes:

  • Improves the error messages for snippets.

Description:
E.g. Instead of saying:
2026-01-07T09:08:42-06:00 ERROR [crates/snippet_provider/src/lib.rs:46] failed to parse snippet
Caused by:
expected an integer

Now the logs give more valuable information like:
2026-01-07T10:47:39-06:00 ERROR [crates/snippet_provider/src/lib.rs:48] invalid snippet in /Users/oscarvarto/Library/Application Support/Zed/extensions/installed/django-snippets/./snippets/python.json (re_path)

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 7, 2026
@SomeoneToIgnore SomeoneToIgnore self-assigned this Jan 8, 2026
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

Since we start to improve things around, let's do a bit more?

let body = snippet.body.to_string();
if snippet::Snippet::parse(&body).log_err().is_none() {
if snippet::Snippet::parse(&body)
.with_context(|| format!("invalid snippet in {} ({})", source.display(), name))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.with_context(|| format!("invalid snippet in {} ({})", source.display(), name))
.with_context(|| format!("invalid snippet '{name}' in {source:?}"))

Can we

  • reword the error a bit to make it more obvious where the snippet name is (not sure if single quotes around are good, just proposing)?

  • do a

if let Err(e) = snippet::Snippet::parse(&body) {
    log::error!("Invalid snippet '{name}' in {source:?}: {e:#}
}

-like change instead of log_err()?

The latter shows quite a backtrace in the settings, which seems totally unneeded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants