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"))
예제 #2
0
 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'))
예제 #3
0
        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))
예제 #4
0
        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))
예제 #5
0
 def put_page(self):
     # Testing parse_on_error=True
     raise HTTPError(int(self.get_argument('code')),
                     json={'error': 'forbidden'})
예제 #6
0
 def get_page_requests_failed(name, data, response):
     raise HTTPError(403, json={'fail_on_error': True})
예제 #7
0
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')
예제 #9
0
 def __init__(self, *args, **kwargs):
     raise HTTPError(401)
예제 #10
0
 def post_page(self):
     raise HTTPError('HTTPError for Sentry')
예제 #11
0
 def put_page(self):
     # Testing parse_on_error=True
     raise HTTPError(401, json={'error': 'forbidden'})
예제 #12
0
 def get_page_requests_failed(self, name, data, response):
     if self.get_argument('default', 'false') != 'true':
         raise HTTPError(403, json={'fail_on_error': True})
예제 #13
0
 def prepare(self):
     raise HTTPError(400, headers={'X-Foo': 'Bar'})
예제 #14
0
 def post_page(self):
     raise HTTPError(403)
예제 #15
0
 def get_page_requests_failed(name, data, response):
     raise HTTPError(403)