Exception: K8s::Error::API

Inherits:
K8s::Error show all
Extended by:
Forwardable
Defined in:
lib/k8s/error.rb

Overview

Kube API error, related to a HTTP response with a non-2xx code

Constant Summary

Constants inherited from K8s::Error

BadRequest, Configuration, Conflict, Forbidden, HTTP_STATUS_ERRORS, InternalError, Invalid, MethodNotAllowed, NotFound, ServerTimeout, ServiceUnavailable, Timeout, Unauthorized, UndefinedResource

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, path, code, reason, status = nil) ⇒ API

Returns a new instance of API.

Parameters:

  • method (Integer)

    HTTP request method

  • path (Integer)

    HTTP request path

  • code (Integer)

    HTTP response code

  • reason (String)

    HTTP response reason

  • status (K8s::API::MetaV1::Status) (defaults to: nil)


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/k8s/error.rb', line 19

def initialize(method, path, code, reason, status = nil)
  @method = method
  @path = path
  @code = code
  @reason = reason
  @status = status

  if status
    super("#{@method} #{@path} => HTTP #{@code} #{@reason}: #{@status.message}")
  else
    super("#{@method} #{@path} => HTTP #{@code} #{@reason}")
  end
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



12
13
14
# File 'lib/k8s/error.rb', line 12

def code
  @code
end

#methodObject (readonly)

Returns the value of attribute method.



12
13
14
# File 'lib/k8s/error.rb', line 12

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



12
13
14
# File 'lib/k8s/error.rb', line 12

def path
  @path
end

#reasonObject (readonly)

Returns the value of attribute reason.



12
13
14
# File 'lib/k8s/error.rb', line 12

def reason
  @reason
end

#statusObject (readonly)

Returns the value of attribute status.



12
13
14
# File 'lib/k8s/error.rb', line 12

def status
  @status
end