tc39/proposal-error-cause

Can we not use extended classes to achieve this goal?

Closed this issue · 3 comments

Users can customize errors, for example:

class MyError extends Error {
    constructor(msg, cause) {
        super(msg);
        this.cause = cause;
    }
}

While there are lots of ways to achieve the behavior of the proposal, if the cause property is explicitly defined by the language, debug tooling can reliably use this info rather than contracting with developers to construct an error properly.

Closed. Feel free to comment or reopen if there are any further questions :)