File: http_error.rb

package info (click to toggle)
ruby-kubeclient 4.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,112 kB
  • sloc: ruby: 4,225; makefile: 6
file content (27 lines) | stat: -rw-r--r-- 688 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

# TODO: remove this on next major version bump
# Deprected http exception
class KubeException < StandardError
  attr_reader :error_code, :message, :response

  def initialize(error_code, message, response)
    @error_code = error_code
    @message = message
    @response = response
  end

  def to_s
    string = "HTTP status code #{@error_code}, #{@message}"
    if @response.is_a?(RestClient::Response) && @response.request
      string += " for #{@response.request.method.upcase} #{@response.request.url}"
    end
    string
  end
end

module Kubeclient
  # Exception that is raised when a http request fails
  class HttpError < KubeException
  end
end