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

Fix error reporting #16

Merged
merged 1 commit into from
Sep 5, 2023
Merged

Fix error reporting #16

merged 1 commit into from
Sep 5, 2023

Conversation

rtsao
Copy link
Collaborator

@rtsao rtsao commented Sep 5, 2023

It seems swc_core::plugin::errors::HANDLER needs to be used instead of swc_core::common::errors::HANDLE, otherwise an inscrutable panic is displayed from @swc/core instead of the intended messages. This was confusing and not actionable.

Other changes:

  • Upgrade SWC
  • Attach AST node span to error messages for context

Before:

thread "«unnamed> panicked at 'cannot access a scoped thread local variable without calling 'set first', /home/runner/.cargo/registry/src/index.cr ates.io-6f17d22bba15001f/scoped-tls-1.0.1/src/lib.rs:168:9

It now looks like:

[Error:
  × useTranslations result function must be passed a string literal or hinted template literal
     ╭─[/path/to/file.js:192:1]
 192 │                 POD
 193 │               </td>
 194 │               <td>
 195 │                 <StatusCircle status={status} /> {translate(statusToKey(status))}
     ·                                                   ──────────────────────────────
 196 │               </td>
 197 │               <td>
 198 │                 {uploader?.firstname} {uploader?.lastname}
     ╰────
] {
  code: 'GenericFailure'
}

@rtsao rtsao merged commit ccb23f5 into main Sep 5, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant