Tuesday, June 19, 2012

Neat and informative error reports with Errorified

Photo by Juhan Sonin
Nobody likes to see an application crash, but when it happens, it's better to have useful information about what went wrong.

A very long time ago, we implemented nicer stack traces in Orbeon Forms, but this did not transfer into nicer information in the server logs. Recently, with the introduction of run modes, we have enforced more strictly the default behavior that users should never see exceptions (of course developers should see them!). So it is even more important that detailed information be logged on the server.

This is what we have done with a little utility we call Errorified. We set it up as a separate repository on github so it can be used independently from Orbeon Forms.

What Errorified does is prepare a neatly-formatted report of what went wrong. This includes Java stack traces, but also, optionally, application-specific stack trace information. In the case of Orbeon Forms, this might include the line numbers in an XForms document.

There are a few other cool things about Errorified:
  • When there are multiple nested exceptions, common parts of the stack traces are not shown.
  • You can set a maximum of stack entries to show for a given trace segment, and the extra entries are elided when needed.
  • It's able to find the cause of exceptions that don't support Java 1.4's getCause() method.
  • It's written in Scala.
You can see a sample report here. There are many ways that this can be improved, so feel free to suggest your own!

No comments:

Post a Comment