Status

()

Core
JavaScript Engine
6 years ago
4 years ago

People

(Reporter: evilpie, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
I would like to completely rewrite our error reporting system.
Also try to avoid edge cases and the weird Error <-> Exception split. There are also quite a few indirections till we actually report a error. I am still looking into how to do this properly, but there is a lot of stuff we could abstract away. I imagine that error reporting once could look like this ThrowError(JSContext *cx, CallArgs args, ErrorType type).
I am not sure how to make vararg errors messages look good.

ThrowError(cx, args, WrongThis);
ThrowError(cx, args, NotEnoughArguments, 3);
ThrowError(cx, args, NotObject, val);

Maybe we could even create translatable error messages ? :)

Comment 1

6 years ago
Error reporting code is severely underloved and I have wasted no small amount of time stepping through the morass while debugging so I applaud your goal.  I would only advise that you take time to understand the exact interaction with the browser (via JSErrorReporter) regarding when things are reported vs. thrown.

Comment 2

6 years ago
Currently error messages and formats are tied to the type of the error -- TypeError, RangeError, SyntaxError, and so on.  We should remove this conflation, at least internally if not (immediately) externally.  In particular the code at the location where an error is thrown should make it immediately clear what sort of error will be thrown.  I suspect we have lingering wrong-error bugs now because of this extra level of indirection.
(Reporter)

Comment 3

6 years ago
So well, I hope i can break the API to make some changes. Should we still have a error struct and only create the error object lazily? I kind of like the idea of only passing around one error object. The think is we expose even more via JSErrorReporter, but the only thing that i see being used in our code, is the actually line of code that threw the error. Maybe we could solve that some other way?
(Assignee)

Updated

4 years ago
Assignee: general → nobody
You need to log in before you can comment on or make changes to this bug.