Skip to content

replace explain-error with clarify-error #81

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

Merged
merged 1 commit into from
Mar 2, 2022
Merged

replace explain-error with clarify-error #81

merged 1 commit into from
Mar 2, 2022

Conversation

staltz
Copy link
Member

@staltz staltz commented Mar 1, 2022

Context

  1. I'd like to use explain-error more often because conceptually it's a neat idea that should A LOT help us when debugging
  2. I had some free time so I wanted to do something small and fun

Problem

explain-error is useful, but it's a bit buggy (when errors don't have a stack it produces a useless "stackless error" string) and it's quite outdated.

Solution

I rewrote the library as clarify-error and it's mostly compatible with explain-error, with the differences:

  • Written in TypeScript (means it probably handles all corner cases better)
  • 100% test coverage
  • A few bytes smaller
  • Renders stackless errors in a nicer way, see below

Before

throw explain('foo', 'bar')
Error: stackless error
    at module.exports (/home/staltz/oss/explain-error/index.js:18:19)
    at Object.<anonymous> (/home/staltz/oss/explain-error/example.js:10:7)

After

throw clarify('foo', 'bar')
Error: bar
    at Object.<anonymous> (/home/staltz/oss/clarify-error/example.js:10:7)
  Error: foo

@staltz staltz requested review from arj03 and mixmix March 1, 2022 21:35
Copy link
Member

@arj03 arj03 left a comment

Choose a reason for hiding this comment

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

Oh this is really good. Nice work. Starred the clarify-error repo. These bad stack traces has been a problem in the SSB stack for a long time.

@staltz
Copy link
Member Author

staltz commented Mar 2, 2022

I might still replace this PR, see staltz/clarify-error#1

@staltz
Copy link
Member Author

staltz commented Mar 2, 2022

Unfortunately pony-cause doesn't support stackless errors so let's go with clarify-error. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants