def handleException(exception): """ Handles an exception that occurs somewhere in the process of handling a request. """ if app.config['DEBUG']: app.log_exception(exception) serverException = exception if not isinstance(exception, exceptions.BaseServerException): serverException = exceptions.getServerError(exception) responseStr = serverException.toProtocolElement().toJsonString() return getFlaskResponse(responseStr, serverException.httpStatus)
def handleException(exception): """ Handles an exception that occurs somewhere in the process of handling a request. """ serverException = exception if not isinstance(exception, exceptions.BaseServerException): with app.test_request_context(): app.log_exception(exception) serverException = exceptions.getServerError(exception) error = serverException.toProtocolElement() responseStr = protocol.toJson(error) return getFlaskResponse(responseStr, serverException.httpStatus)