mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 19:06:09 +00:00
Move @has_request_variables error responses to middleware
This will now allow us to use @has_request_variables on helper functions. (imported from commit 799d71477654eac7fd8192cfc5bb88b78053532d)
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
from decorator import RequestVariableMissingError, RequestVariableConversionError
|
||||
from zephyr.lib.response import json_error
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
@@ -23,3 +26,9 @@ class LogRequests(object):
|
||||
% (remote_ip, request.method, response.status_code,
|
||||
time_delta, request.get_full_path()))
|
||||
return response
|
||||
|
||||
class JsonErrorHandler(object):
|
||||
def process_exception(self, request, exception):
|
||||
if hasattr(exception, 'to_json_error_msg') and callable(exception.to_json_error_msg):
|
||||
return json_error(exception.to_json_error_msg())
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user