Martin Pinner
Martin Pinner I'm one of the co-founders of Application Performance Ltd.

A guide to solving Java application errors in production - part 1

A guide to solving Java application errors in production - part 1

AP is proud to sponsor “The complete guide to Solving Java Application Errors in Production” written by Alex Zhitnitsky at our friends OverOps. This blog is the first of a 3-part series looking at each of the chapters. The book kicks off with what is probably the most contentious chapter: “Keep it Actionable: What’s the Purpose of Using Exceptions”. OverOps take the view that an exception implies there is a bug in your code and that it should be fixed. In other words, exceptions should always be actionable. There should be no such thing as an non-actionable exception.

You can use OverOps to identify the cause of the exception, as it gives you the line of code and the variable values in play at the time. In this way you can reduce the number of exceptions in your application, eventually to zero. As a consequence you will improve the quality of your code and, by extension, the experience of your users using your application. It is a worthwhile aim. I certainly agree that exceptions should be rare as they are relatively expensive to execute compared with normal control flow, and usually involve a lot of logging, but in practice I think it will be difficult to remove all exceptions from an application.

Ultimately an exception is thrown when a method cannot fulfil its contract. There are ways you can try to mitigate the likelihood of an exception being thrown, and that is a good thing as it allows you to see the wood for the trees, but exceptions are a guaranteed backstop should you fail to cover all the cases.

What do you think? Take a read and let us know.