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 ? :)
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.
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.
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?
You need to log in before you can comment on or make changes to this bug.