14. Failing Gracefully
Like input validation, error handling is a very important aspect of web applications, but it is hard to get done right. Without proper error handling, uncaught exceptions in the application (e.g., a RuntimeException
or a transaction-related exception) would propagate out of the web framework and cause a generic “Internal Server Error” (HTTP error code 500). The user would see a page full of technical jargon and a partial stack trace of the exception itself (see Figure 14.1., “An uncaught exception from the Seam event handler method”). That is certainly unprofessional. Instead, we should try to fail gracefully and display a nice custom error page for the user.
Figure 14.1. An uncaught exception from the Seam event handler ...
Get JBoss® Seam: Simplicity and Power Beyond Java™ EE now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.