-
Notifications
You must be signed in to change notification settings - Fork 165
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
Allowing throwing an exception with a specific message #1374
Comments
You can add properties to the TypeError. That seems better? (It's not currently possible in Web IDL, but we'd add that.) |
Yeah maybe. @littledan @syg thoughts from a JS perspective? Having said, I think that eventually standardizing messages would be good too, but if we can avoid them being the sole mechanism to rely on that would be a lot better. |
Does this mean adding data properties to |
Yep, that's what I meant. (Or, I guess, own accessor properties, but own data properties would make more sense.) |
Node uses I don't see any problems with it from the JS side, though it's unlikely that errors thrown by JS would get such a property in the near future. Do note that this can make optimizations which are formally (but not practically) unobservable suddenly be observable: right now if there's two adjacent steps which throw a TypeError and no user code runs between them, an engine can do those steps in whichever order is more convenient for it, and with this change would be required to do them in a particular order. But that's only very rarely going to be an issue, I think, and in any case users already depend on the unspecified message strings and so practically many of these things are observable anyway. |
What problem are you trying to solve?
fetch()
throws aTypeError
and callers distant from thefetch()
call are having a hard time. As we cannot extendTypeError
, the current best idea is to standardize on the message: whatwg/fetch#526.If anyone has better ideas I'd very much appreciate them.
What solutions exist today?
None.
How would you solve it?
Allow create and throw to be passed an optional message argument.
Anything else?
This vaguely relates to #1024.
The text was updated successfully, but these errors were encountered: