Elements of Enterprise-Grade Web Frameworks – Part 11: Friendly Error Messages and Error Logging

Error HandlingError messages are one of the few places where programmers can showcase their latent literary talents. Unfortunately, most developers are not Shakespeare, nor were meant to be, and so an effective framework that helps automate error message generation is key to a successful enterprise-grade system.

Proper error messages should contain two key points: 1) Why the user’s requested action did not go through, and 2) What the user needs to do to fix it. More extensive applications with documentation should link to supplemental materials for further reading, while multilingual systems will need to utilize translation tables for error message generation. Moreover, every possible error path should be handled in some way, whether through custom or generic error messages, or in case an unexpected error has occurred, through automated logging and notification. One of the most frustrating experiences for users can be poorly-written error messages, whether expected or unexpected, and a good system will make sure that users are hand-held throughout the error process.

In addition to generating error messages, unexpected or high-alert errors should be thoroughly logged and sent to system administrators. Unexpected errors, for instance, might occur if an essential system service is down, or a software upgrade change functionality of a system module. High-alert errors, on the other hand, might include hacking attempts or invalid user access attempts to sensitive data. Logging these errors and alerts is critical to debugging, both to assuage the scope of a problem, to help diagnose the causes, and to develop a solution. While users often offer vague descriptions of errors, a good logger will provide the exact error message, time that it occurred, and events leading up to the problem. A web app error logger should store both the error message, the page that generated the error, and the relevant GET and POST variables. The error logger will also need to filter sensitive information per regulatory constraints when logging this data.

Out of the major web development frameworks, most offer some scope of validation and error handling. PHP’s error handling is possibly the worst out of the major frameworks, by often simply showing a blank or partially-loaded page without identifying information. The primary redeeming quality of PHP is its excellent logging through the Apache and Linux log files, which make debugging apps a breeze.

ASP.NET, on the other hand, offers extensive validation and error-handling functionality. With many hooks and techniques for implementation of error handling, both at the page and application level, it by far has the most extensive error-handling capabilities. Unfortunately, many of its built-in error messages are obtuse and long-winded, requiring delving through reams of digital documentation and help forums to diagnose and fix the problem. Error logging is also poorly implemented on the ASP.NET framework compared to PHP, requiring use of the Windows Event Log or advanced IIS debugging, both of which are much less friendly than LAMP’s simple text logs and “tail” command.

Node.js, Rails, and Django all run their own custom servers, with varying error logging and debugging capabilities. Node.js offers the most thorough debugging out of the three, with built-in step-through of the web server. Rails and Django do offer advanced error handling, however it is on par with ASP.NET, albeit with slightly worse documentation. Less mature, evolving frameworks often require delving through the application source code or fighting against undocumented capabilities to implement desired functionality.

Overall, no single web application framework offers a balanced mix of simple, automated logging with email notifications, cohesive, friendly error messages, and advanced exception handling. Each framework requires custom development and integration for a fully functional solution. Join us for the last article in this series, where we dive deeper into form input validation and conclude this set of articles on enterprise-grade web frameworks.

Written by Andrew Palczewski

About the Author
Andrew Palczewski is CEO of apHarmony, a Chicago software development company. He holds a Master's degree in Computer Engineering from the University of Illinois at Urbana-Champaign and has over ten years' experience in managing development of software projects.
Google+

RSS Twitter LinkedIn Facebook Email

Leave a Reply

Your email address will not be published. Required fields are marked *