Exception handling

This article is part of our exception handling article series.
Learn more about exception handling

Always reproduce errors

When you have got a bug report from a user or found an exception in the log it can be easy to make an assumption about why an exception was thrown.

Don't do that.

Make sure that you can reproduce the error. The motivation is the same as for red-green-refactor when writing unit tests.

If you cannot prove that you have found the root cause of the error, you are probably "fixing" the wrong part of the code base.

By doing so you are worsening the code base with a workaround instead of making it better. What's worse is that it will be harder to find the root cause as you have hidden one of the symptoms of it.

Conclusion

If you cannot reproduce an error, you are not looking in the right part of the code base.