Raises exception Net::XXX (http error code) if an http error occured
778869
def handle_response
      handle_deflation
      case last_response
      when Net::HTTPMultipleChoice, # 300
        Net::HTTPMovedPermanently, # 301
        Net::HTTPFound, # 302
        Net::HTTPSeeOther, # 303
        Net::HTTPUseProxy, # 305
        Net::HTTPTemporaryRedirect
        if last_response.key?('location')
          options[:limit] -= 1
          self.path = last_response['location']
          self.redirect = true
          self.http_method = Net::HTTP::Get unless options[:maintain_method_across_redirects]
          capture_cookies(last_response)
          perform
        else
          last_response
        end
      else
        Response.new(last_response, parse_response(last_response.body))
      end
    end
927824
def handle_exception!(boom)
      @env['sinatra.error'] = boom

      if boom.respond_to? :http_status
        status(boom.http_status)
      elsif settings.use_code? and boom.respond_to? :code and boom.code.between? 400, 599
        status(boom.code)
      else
        status(500)
      end

      status(500) unless status.between? 400, 599

      if server_error?
        dump_errors! boom if settings.dump_errors?
        raise boom if settings.show_exceptions? and settings.show_exceptions != :after_handler
      end

      if not_found?
        headers['X-Cascade'] = 'pass'
        body '<h1>Not Found</h1>'
      end

      res = error_block!(boom.class, boom) || error_block!(status, boom)
      return res if res or not server_error?
      raise boom if settings.raise_errors? or settings.show_exceptions?
      error_block! Exception, boom
    end
380284
def with_soap_error_handling &block
      yield
    rescue Savon::HTTPError => e
      e = ::AkamaiApi::Unauthorized if e.http.code == 401
      raise e
    end
1230743
def validate(response)
      case response.code
        when 400; raise Error::BadRequest.new error_message(response)
        when 401; raise Error::Unauthorized.new error_message(response)
        when 403; raise Error::Forbidden.new error_message(response)
        when 404; raise Error::NotFound.new error_message(response)
        when 405; raise Error::MethodNotAllowed.new error_message(response)
        when 409; raise Error::Conflict.new error_message(response)
        when 500; raise Error::InternalServerError.new error_message(response)
        when 502; raise Error::BadGateway.new error_message(response)
        when 503; raise Error::ServiceUnavailable.new error_message(response)
      end

      response.parsed_response
    end
448139
def request(*args)
      response = make_request(*args)
      # binding.pry unless response.kind_of?(Net::HTTPSuccess)
      raise HTTPError, response unless response.is_a?(Net::HTTPSuccess)
      response
    end
1089330
def rescue_status_code_exception(&blk)
      yield
    rescue HtmlUnit::FailingHttpStatusCodeException => e
      raise NavigationException, e.message, caller
    end
916184
private static function catchError()
    {
        switch (json_last_error()) {
            case JSON_ERROR_NONE:
                self::$error = false;
                break;
            case JSON_ERROR_DEPTH:
                self::$error = 'Maximum stack depth exceeded';
                break;
            case JSON_ERROR_STATE_MISMATCH:
                self::$error = 'Underflow or the modes mismatch';
                break;
            case JSON_ERROR_CTRL_CHAR:
                self::$error = 'Unexpected control character found';
                break;
            case JSON_ERROR_SYNTAX:
                self::$error = 'Syntax error, malformed JSON';
                break;
            case JSON_ERROR_UTF8:
                self::$error = 'Malformed UTF-8 characters, possibly incorrectly encoded';
                break;
            default:
                self::$error = 'Unknown error';
                break;
        }
    }
1275641
async def handle_exception(self, exc: Exception, action: str, request_id):
        
        if isinstance(exc, APIException):
            await self.reply(
                action=action,
                errors=self._format_errors(exc.detail),
                status=exc.status_code,
                request_id=request_id
            )
        elif exc == Http404 or isinstance(exc, Http404):
            await self.reply(
                action=action,
                errors=self._format_errors('Not found'),
                status=404,
                request_id=request_id
            )
        else:
            raise exc
1241396
def getErrorInfoFromResponse
      if @responseXMLdoc
         errcode = getResponseValue( :errcode )
         @errcode = errcode ? errcode : ""
         errtext = getResponseValue( :errtext )
         @errtext = errtext ? errtext : ""
         errdetail = getResponseValue( :errdetail )
         @errdetail = errdetail ? errdetail : ""
         if @errcode != "0"
            @lastError = "Error code: #{@errcode} text: #{@errtext}: detail: #{@errdetail}"
         end
      end
      @lastError
   end
1307990
function HTTPError(statusCode, message) {
    if (!(this instanceof HTTPError)) {
      return new HTTPError(statusCode, message);
    }

    assert(statusCode >= 400, 'Not a valid HTTP error code');

    this.statusCode = statusCode;
    this.code = statusCode;
    this.message = message || defaultMessage;
  }
66522
def create_api_error_from_http_exception(e):
    
    response = e.response
    try:
        explanation = response.json()['message']
    except ValueError:
        explanation = (response.content or '').strip()
    cls = APIError
    if response.status_code == 404:
        if explanation and ('No such image' in str(explanation) or
                            'not found: does not exist or no pull access'
                            in str(explanation) or
                            'repository does not exist' in str(explanation)):
            cls = ImageNotFound
        else:
            cls = NotFound
    raise cls(e, response=response, explanation=explanation)
1270852
def _http_error_handler(http_error):
    ''' '''
    message = str(http_error)
    error_code = None

    if 'x-ms-error-code' in http_error.respheader:
        error_code = http_error.respheader['x-ms-error-code']
        message += ' ErrorCode: ' + error_code

    if http_error.respbody is not None:
        message += '\n' + http_error.respbody.decode('utf-8-sig')

    ex = AzureHttpError(message, http_error.status)
    ex.error_code = error_code

    raise ex
719667
def rescue_http_error(exception)
      # we need to call it before we assign the variables
      body = self.render_http_error(exception)
      [exception.status, exception.headers, body]
    end
378385
def _catch_index_error(self, response):
        
        code, headers, raw_data = response
        if not raw_data:
            return
        data = json.loads(raw_data)
        if not data or not data.get('errors'):
            return
        try:
            error_dict = data['items'][0]['index']
            message = error_dict['error']
        except (KeyError, IndexError):
            return
        raise exception_response(400, detail=message)
631641
function httpInternalError(req, res, err) {
    console.error(err);
    res.writeHead(500, { 'Content-Type': 'text/plain' });
    res.write(`Error 500 Internal server error: ${err}`);
    res.end();
}
233278
def raise_if_error(frame):
    
    if "status" not in frame or frame["status"] == b"\x00":
        return
    codes_and_exceptions = {
        b"\x01": exceptions.ZigBeeUnknownError,
        b"\x02": exceptions.ZigBeeInvalidCommand,
        b"\x03": exceptions.ZigBeeInvalidParameter,
        b"\x04": exceptions.ZigBeeTxFailure
    }
    if frame["status"] in codes_and_exceptions:
        raise codes_and_exceptions[frame["status"]]()
    raise exceptions.ZigBeeUnknownStatus()
1356264
def http_error_default(self, url, fp, errcode, errmsg, headers):
        """"""
        fp.close()
        raise HTTPError(url, errcode, errmsg, headers, None)