Hi! I’m looking to improve how my addons report errors.
For example, if a developer is using Mirage and tries to use the association()
helper on an self-referential belongsTo relationship, they’d see the following white screen & error message:
Zooming in on the console:
There’s a few things I don’t like about this already:
- There are two dropdowns. Which should the developer click?
- The primary error message is too hidden/tucked away.
If I click the first dropdown this is what I get:
which is not super useful.
Here’s the second dropdown:
Here we see at least part of the error message. I can hover over message
and see the full text:
The stack
key also has the message, and the useful stack trace leading to the problematic line of code in the app.
I think for these reasons, at some point I added these lines
console.error(this.message);
console.error(this);
to Mirage’s assert()
method, which results in a console that looks like this:
There’s a lot more noise going on here, but I like that the primary message is printed in full to the console. If you click it, you also get a useful stack trace:
I think Mirage’s case is complicated because it typically handles things asynchronously, though I’m not sure if that’s what’s happening in this specific case.
In general, I’m looking to improve the error reporting across lots of my projects. I guess my main questions are:
- What are some ways this story could be improved? In particular, getting the primary message to users first, and a meaningful stack trace second.
- How can I be a “good citizen” of the ecosystem, so errors from my addons behave the same as others?
- Are there some examples of exceptional addons or libraries that anyone could point me to for examples of prior art here?
Thanks for any tips!