This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 147
Should Error.code be readonly? #113
Labels
Comments
Hi @clintwood! We're following Node's behavior here. See internal/errors. Node is starting to increase usage of its |
Thanks for opening the rollup issue. |
v0.11.1 is released 🎉 |
Fixed in Node nodejs/node@42a2a9b too 🎉 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm using Rollup which modifies the
code
property on a caughtError
object to augmentError.code
for their specific context.In
@std/esm
Error.code
is defined as a getter so whenrollup
tries to 'augment' the error by settingcode
I get an error thrown by rollup,TypeError: Cannot set property code of [object Object] which has only a getter
, which is wholly misleading.I noticed that if you create a standard
Error
object in Node there is nocode
property by default and one is free to add or modify it at will.So
code
should probably be a writable prop so that libraries like Rollup can 'augment' errors to be more specific for their unique contexts! This case may not be unique to Rollup as other libraries may do the same!PS I couldn't find any specs on the how an
Error
object should behave - but didn't look too hard ;)The text was updated successfully, but these errors were encountered: