Challenges of Exception Handling
Let’s consider a JavaEE web application with an API exposed via RESTful endpoints. Exceptions… They are just everywhere and of course they will be raised in our API as well. As such during development of API following challenges will emerge:
- security risks – sensitive data from exceptions could leak from server to the client’s side;
- complicated API adoption – indistinguishably or hardly identifiable exceptions makes it hard to handle them on a client’s side and as consequence renders bad user experience (some user scenarios behave unpredictably or simply dumb);
- complicated troubleshooting in production – support dude must have an ability to localize in a moment any failure point happened in the past in logs / system journals.