Best practices for error reporting in addons

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!

My personal opinion is that Ember should offer a logger. They do but it is deprecated and private. I guess the idea was that the console api was enough.

Sadly you’ve demonstrated that the plain console API is not enough.

Maybe there could be a common logger for addons? Could the infamous debug module could be useful in this regard?

I am surprised this topic hasn’t gotten more discussion.

@sukima Are you proposing something like warn but for errors?

um maybe? I mean there is always assert. I think I was suggesting a comon API for logging and since Ember’s logger is deprecated and private I was suggesting the de facto standard in the node.js world: debug - npm