fix(verror)!: make cause a spec-compliant property - #21
Conversation
VError.prototype.cause and WError.prototype.cause were function-style
accessors predating the language's native Error.cause. Replace them
with an instance property matching the native Error.cause with a
real, non-enumerable, writable instance property set on construction
(writable, non-enumerable, configurable).
Updates lib/index.d.ts, api.md, and all test call sites accordingly.
BREAKING CHANGE: err.cause() and err.cause(newCause) are no longer
callable. Use err.cause to read the cause, and pass { cause } to the
constructor to set it. WError's cause setter form is removed for the
same reason.
tsd@0.7.x bundles typescript@^3.0.1, too old to parse current @types/node syntax, causing thousands of errors. Upgrading to tsd@^0.33.0 fixes this and surfaces a few real type-test inaccuracies, also fixed here.
nerror has no committed lockfile, so installs can pull transitive deps that require newer Node (e.g. brace-expansion@5) and fail unpredictably. Declaring an engines floor surfaces this explicitly. This feels reasonable as nerror 2.0.0 is not expected to be used or work with node versions older than 20.
7be0d1a to
b9bcc18
Compare
| if (cause) { | ||
| VError._assertError(cause, '"cause" must be an Error'); | ||
| this.jse_cause = cause; | ||
| Object.defineProperty(this, 'cause', { |
There was a problem hiding this comment.
I think it's reasonable to replace jse_cause and not maintain 2 identical props w/ different names, since this is breaking anyway. That being said, I'm not sure if jse_cause is used directly somewhere, or if there's value in keeping it
There was a problem hiding this comment.
(I don't have the full context) It seems jse_cause is used (as a concept) in other repos: https://sourcegraph.netflix.io/search?q=context:global+jse_cause&patternType=keyword&sm=0 (so I would say it should stay and could be marked as deprecated?)
There was a problem hiding this comment.
I just noticed you increased the version to 2.x... so ignore the deprecation note, I just wonder why was jse_cause created 🤔
There was a problem hiding this comment.
I think nerror was based on verror, which used things like jse_cause, jse_info, etc. for a number of things. Unfortunately that's all the context I have 😅
Uh oh!
There was an error while loading. Please reload this page.