Log errors and send 500 status code

Use this mechanism instead of exceptions as web service will always be
accessed by a HTTP client instead of directly as a class