def accumulate(xml, response): if response.code >= 400: raise HTTPError( 503, "remote server returned error with code =" + str(response.code)) if xml is None: raise HTTPError(503) handler.result += int(xml.findtext("a"))
def accumulate(xml, response): if response.code >= 400: raise HTTPError( 503, 'remote server returned error with code {}'.format( response.code)) if xml is None: raise HTTPError(503) self.result += int(xml.findtext('a'))
def _fail_on_error_wrapper(name, data, response): error_method_name = handler_method_name + '_requests_failed' if hasattr(self, error_method_name): getattr(self, error_method_name)(name, data, response) status_code = response.code if 300 <= response.code < 500 else 502 raise HTTPError(status_code, 'HTTP request failed with code {}'.format(response.code))
def _httpfuture_fail_on_error_result_check(name, future): result = future.result() if not result.response.error and not result.exception: return error_method_name = handler_method_name + '_requests_failed' if hasattr(self, error_method_name): getattr(self, error_method_name)(name, result.data, result.response) status_code = result.response.code if 300 <= result.response.code < 500 else 502 raise HTTPError(status_code, 'HTTP request failed with code {}'.format(result.response.code))
def put_page(self): # Testing parse_on_error=True raise HTTPError(int(self.get_argument('code')), json={'error': 'forbidden'})
def get_page_requests_failed(name, data, response): raise HTTPError(403, json={'fail_on_error': True})
def second_preprocessor(handler, callback): if handler.get_argument('fail', 'false') == 'true': raise HTTPError(503, 'error in preprocessor') else: handler.text += ' 2' callback()
def _inner(): raise HTTPError(500, 'fail')
def __init__(self, *args, **kwargs): raise HTTPError(401)
def post_page(self): raise HTTPError('HTTPError for Sentry')
def put_page(self): # Testing parse_on_error=True raise HTTPError(401, json={'error': 'forbidden'})
def get_page_requests_failed(self, name, data, response): if self.get_argument('default', 'false') != 'true': raise HTTPError(403, json={'fail_on_error': True})
def prepare(self): raise HTTPError(400, headers={'X-Foo': 'Bar'})
def post_page(self): raise HTTPError(403)
def get_page_requests_failed(name, data, response): raise HTTPError(403)