biome icon indicating copy to clipboard operation
biome copied to clipboard

📎 Improve internal error reporting

Open Conaclos opened this issue 2 months ago • 5 comments

Description

#2659 brought something to light for me: internal error reporting is uninformative for users and doesn't help them to understand the source of the issue or how to find a workaround.

Biome is a toolchain, a bug can come from any tool, and it is hard to tell without investment of the user.

It would be nice if we could specify which tool caused the error, and even in what unit of work (e.g. a rule for the linter), and the linted/formatted node - if any - (the queried node in the case of the linter).

Taking #2659 as an example. Here is the current error:

Biome encountered an unexpected error

This is a bug in Biome, not an error in your code, and we would
appreciate it if you could report it to
https://github.com/biomejs/biome/issues/ along with the
following information to help us fixing the issue:

Source Location: crates/biome_js_semantic/src/semantic_model/scope.rs:115:33
Thread Name: biome::worker_0
Message: no entry found for key

types.ts internalError/panic  INTERNAL  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ processing panicked: no entry found for key
  
⚠ This diagnostic was derived from an internal Biome error.
  Potential bug, please report it if necessary.

And here is an example of a better diagnostic:

types.ts internalError/panic  INTERNAL  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ Biome encountered an internal error while linting the file with the
 rule suspicious/noRedeclare on the following code

    1 │
  > 2 │ type Element<T> = T extends Array<infer U> ? U : never
    3 │ 

ℹ This diagnostic was derived from the following internal Biome error:
 Source Location: crates/biome_js_semantic/src/semantic_model/scope.rs:115:33
 Thread Name: biome::worker_0
 Message: no entry found for key

ℹ This is a bug in Biome, not an error in your code, and we would
 appreciate it if you could report it to
 https://github.com/biomejs/biome/issues/

ℹ As a workaround try to disable the lint rule suspicious/noRedeclare
 or ignoring the file `types.ts`.

Conaclos avatar May 05 '24 22:05 Conaclos