How to report errors from package?


Say I write a package atom-foo that calls some external program foo. Say that the user doesn’t have foo. An error will happen. Very good. How do I report this error, though?

Naively, I tried console.error, and that did print to the console just fine, but it doesn’t seem to automatically open the console after an error has been printed, so the poor user has no idea what has gone wrong.

So I tried to embed a div outlet into my view, and “printed” my error message into that. That worked fine. But when I added styling to this div, I knew that it was the wrong approach: for sure, we want different errors to look similar, and we don’t want one package author to show black text on red background whereas the next package author opts for red text on black background…


Try atom.confirm. I haven’t tried it yet but it is in the api docs.


First of all, you should always follow the styleguide, that will give everything the correct visual appearance. Just activate it from within Atom to see what styles are available. Specific theme colors variables (these are used by the core styles), are always accessible from any LESS file by importing ui-variables.

As for your main point of concern, there is currently no core functionality for displaying error messages. Until that gets implemented, you can use something like atom-message-panel. A number of other package authors use it already, with great success.