Catch JSON encoding exceptions

All exceptions should be transmitted to the client correctly. JSON
encoding of the response body was not guarded so these exceptions would
result in a null response body.