Handles all responses which return an error status code
322686
def _handle_error(self, response):
        
        auth_msg = "The query could not be completed. Invalid auth token."

        status_code = response.status_code
        if 400 <= status_code < 500:
            if status_code == 400:
                raise auth_error(auth_msg)
            else:
                raise auth_error("The query could not be completed. "
                                 "There was a client-side error with your "
                                 "request.")
        elif 500 <= status_code < 600:
            raise auth_error("The query could not be completed. "
                             "There was a server-side error with "
                             "your request.")
        else:
            raise auth_error("The query could not be completed.")
1073408
def check_status_code(response, codes=None):
    
    codes = codes or [200]
    if response.status_code not in codes:
        raise StatusCodeError(response.status_code)
232756
function handleCallback(callback, err, httpResponse, body) {

    if(err){
        return callback(err);
    }

    //
    // API returns error
    //
    if( body.status !== 'OK' ){
        return callback(new Error(body.comment));
    }

    return callback(null, body.result);
}
135497
def error_response(
    error_type="Internal server error",
    error_text="",
    status=400,
    participant=None,
    simple=False,
    request_data="",
):
    """"""
    last_exception = sys.exc_info()
    if last_exception[0]:
        db.logger.error(
            "Failure for request: {!r}".format(dict(request.args)),
            exc_info=last_exception,
        )

    data = {"status": "error"}

    if simple:
        data["message"] = error_text
    else:
        data["html"] = (
            error_page(
                error_text=error_text,
                error_type=error_type,
                participant=participant,
                request_data=request_data,
            )
            .get_data()
            .decode("utf-8")
        )
    return Response(dumps(data), status=status, mimetype="application/json")
330883
def process_response(response)
        raise ArgumentError, 'response is null' if response.nil?

        if block_given?
          yield
        end


        # return code
        if 401 == response.code
          raise UnauthorizedError, compose_error_message(response)
        elsif 500 == response.code
          raise ServerError, compose_error_message(response)
        elsif 2 != (response.code / 100)
          raise OrientdbError, "unexpected return code, code=#{response.code}, body=#{compose_error_message(response)}"
        end

        content_type = response.headers[:content_type] if connection_library == :restclient
        content_type = response.headers['Content-Type'] if connection_library == :excon
        content_type ||= 'text/plain'

        rslt = case
          when content_type.start_with?('text/plain')
            response.body
          when content_type.start_with?('application/x-gzip')
            response.body
          when content_type.start_with?('application/json')
            ::JSON.parse(response.body)
          else
            raise OrientdbError, "unsuported content type: #{content_type}"
          end

        rslt
      end
744402
def handle_error(self, error, req, schema, error_status_code, error_headers):
        
        status_code = error_status_code or self.DEFAULT_VALIDATION_STATUS
        abort(
            status_code,
            exc=error,
            messages=error.messages,
            schema=schema,
            headers=error_headers,
        )
1130939
def handle_error(self, error, req, schema, error_status_code, error_headers):
        
        status_code = error_status_code or self.DEFAULT_VALIDATION_STATUS
        if status_code == 422:
            reason = "Unprocessable Entity"
        else:
            reason = None
        raise HTTPError(
            status_code,
            log_message=str(error.messages),
            reason=reason,
            messages=error.messages,
            headers=error_headers,
        )
238044
def _method_response_handler(self, response: Dict[str, Any]):
        
        code = response.get("CODE")
        if code in (200, 300):
            self._result_handler(response)
        else:
            asyncio.ensure_future(self._gen_result_handler(response))
993310
def handle_error(r, expected_code):
    
    code = r.status_code
    if code != expected_code:
        info = 'API response status code {}'.format(code)
        try:
            if 'detail' in r.json():
                info = info + ": {}".format(r.json()['detail'])
            elif 'metadata' in r.json():
                info = info + ": {}".format(r.json()['metadata'])
        except json.decoder.JSONDecodeError:
            info = info + ":\n{}".format(r.content)
        raise Exception(info)
669215
def handle_error(err, halt=True):
        
        print('{}{}{}'.format(c.Style.BRIGHT, c.Fore.RED, err))
        if halt:
            sys.exit(1)
801500
def _process_async_error(self, resp_body, error_class):
        
        def _fmt_error(err):
            # Remove the cumbersome Java-esque message
            details = err.get("details", "").replace("\n", " ")
            if not details:
                details = err.get("message", "")
            return "%s (%s)" % (details, err.get("code", ""))

        error = resp_body.get("error", "")
        if "failedItems" in error:
            # Multi-error response
            faults = error.get("failedItems", {}).get("faults", [])
            msgs = [_fmt_error(fault) for fault in faults]
            msg = "\n".join(msgs)
        else:
            msg = _fmt_error(error)
        raise error_class(msg)
1039652
def handle_response(defopts, res)
      raise NetError.new(res.body)  unless res.code == '200'

      json = Yajl::Parser.parse(res.body)
      RegApi2.got_response(json)

      raise ApiError.from_json(json)  if json['result'] == 'error'

      res_contract = RegApi2::ResultContract.new(defopts)
      res_contract.handle_result(json)
    end
802111
def handle_request_parsing_error(err, req, schema, error_status_code, error_headers):
    
    abort(error_status_code, errors=err.messages)
38451
def _handler_response(self, response, data=None):
        
        if response.status_code == 200:
            data = response.json()
            if isinstance(data, dict) and data.get("error_code"):

                raise WeiboAPIError(data.get("request"), data.get("error_code"), data.get("error"))
            else:
                return data
        else:
            raise WeiboRequestError(
                "Weibo API request error: status code: {code} url:{url} ->"
                " method:{method}: data={data}".format(
                    code=response.status_code,
                    url=response.url,
                    method=response.request.method,
                    data=data
                )
            )
924120
function handleError(res) {
  return function (err) {
    if (err.status && err.name !== 'NotFoundError') {
      // If we're in this block, the error has a defined `status` property and
      // the error should be directed out immediately
      sendDefaultResponseForCode(err.status, err.message, res);
    } else if (err.name === 'NotFoundError' ||
      err.message.indexOf('ENOENT') !== -1 ||
      err.message.indexOf('not found') !== -1) {
      notFound(err, res);
      // if the word "client" is ever in a message, it should be for the client.  We enforce that here.
    } else if (err.message.indexOf('Client') !== -1) {
      clientError(err, res);
    } else {
      serverError(err, res);
    }
  };
}
867664
def handle_exception(error):
    """"""
    try:
        if _get_acceptable_response_type() == JSON:
            response = jsonify(error.to_dict())
            response.status_code = error.code
            return response
        else:
            return error.abort()
    except InvalidAPIUsage:
        # In addition to the original exception, we don't support the content
        # type in the request's 'Accept' header, which is a more important
        # error, so return that instead of what was originally raised.
        response = jsonify(error.to_dict())
        response.status_code = 415
        return response
1096894
def handle_error(self, request: Any, status: int = 500, exc: Any = None, message: Optional[str] = None) -> web.Response:
        """"""
        if self.transport is None:
            # client has been disconnected during writing.
            if self._access_log:
                request_ip = RequestHandler.get_request_ip(request, None)
                version_string = None
                if isinstance(request.version, HttpVersion):
                    version_string = 'HTTP/{}.{}'.format(request.version.major, request.version.minor)
                logging.getLogger('transport.http').info('[{}] [{}] {} {} "{} {}{}{}" - {} "{}" -'.format(
                    RequestHandler.colorize_status('http', 499),
                    RequestHandler.colorize_status(499),
                    request_ip or '',
                    '"{}"'.format(request._cache['auth'].login.replace('"', '')) if request._cache.get('auth') and getattr(request._cache.get('auth'), 'login', None) else '-',
                    request.method,
                    request.path,
                    '?{}'.format(request.query_string) if request.query_string else '',
                    ' {}'.format(version_string) if version_string else '',
                    request.content_length if request.content_length is not None else '-',
                    request.headers.get('User-Agent', '').replace('"', '')
                ))

        headers = {}
        headers[hdrs.CONTENT_TYPE] = 'text/plain; charset=utf-8'

        msg = '' if status == 500 or not message else message

        headers[hdrs.CONTENT_LENGTH] = str(len(msg))
        headers[hdrs.SERVER] = self._server_header or ''
        resp = web.Response(status=status,  # type: ignore
                            text=msg,
                            headers=headers)  # type: web.Response
        resp.force_close()  # type: ignore

        # some data already got sent, connection is broken
        if request.writer.output_size > 0 or self.transport is None:
            self.force_close()  # type: ignore
        elif self.transport is not None:
            request_ip = RequestHandler.get_request_ip(request, None)
            if not request_ip:
                peername = request.transport.get_extra_info('peername')
                if peername:
                    request_ip, _ = peername
            if self._access_log:
                logging.getLogger('transport.http').info('[{}] [{}] {} {} "INVALID" {} - "" -'.format(
                    RequestHandler.colorize_status('http', status),
                    RequestHandler.colorize_status(status),
                    request_ip or '',
                    '"{}"'.format(request._cache['auth'].login.replace('"', '')) if request._cache.get('auth') and getattr(request._cache.get('auth'), 'login', None) else '-',
                    len(msg)
                ))

        return resp