I think returning a 200 with an “error contract” makes parsing even more difficult for clients (when should I expect an error? When a normal response?). I think this problem can be tackled from two angles: the first one, not every exception is a 5xx (if we’re talking about APIs that go through http). You need to handle exceptions properly understanding that a RemoteInvocationException from an external service is not the same as a NumberFormatException when parsing request params. The second approach is using circuit breakers. When your service requires an external source (DB, another API, an FTP, a file in a NFS (?, etc) you need to be ready to open the circuit and stop hitting it in case it’s down. Hystrix is one of the options to do this. Doing these two things should keep the DevOps chaps happier :)

Written by

Technology enthusiast. Less is more.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store