@Override public Response toResponse(MongoServerException exc) { logger.error("Got mongo server exception", exc); final Status errorCode = Status.INTERNAL_SERVER_ERROR; return Response.status(errorCode) .entity(new ErrorMessage( errorCode.getStatusCode(), "Database exception: " + exc.getCode(), exc.getLocalizedMessage() )).build(); }