blakeembrey / blakeembrey/javascript-stringify

Handle different error types

Open
#39 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
146
Forks
16
PR merge metrics
No merged PRs in 30d

Description

Currently, all error types seem to be represented as `new Error()`. Other error types like `SyntaxError`, `ReferenceError` etc, are not serialized any differently

Suggestion:

```js
stringify(new SyntaxError('syntax')); // "new SyntaxError(syntax')"
stringify(new ReferenceError('syntax')); // "new ReferenceError(syntax')"
...
```

It should be possible to do this using [`Error.prototype.name`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name) with the caveat that it can be overridden to an empty string, which should probably be handled

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the serializer entry point that implements stringify and inspect how Error.prototype.name is handled. Done means SyntaxError, ReferenceError, and other named errors serialize with their names, while an overridden empty name is handled consistently; verify using equivalent stringify examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.