Exception: Kube::CommandError
- Defined in:
- lib/kube/errors.rb
Overview
Raised when a kubectl command fails.
begin
resource.patch
rescue Kube::CommandError => e
e.subcommand # => "patch"
e.stderr # => "Error from server (NotFound): ..."
e.exit_code # => 1
e.reason # => "NotFound" (parsed from stderr, or nil)
end
Instance Attribute Summary collapse
-
#exit_code ⇒ Object
readonly
Returns the value of attribute exit_code.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#subcommand ⇒ Object
readonly
Returns the value of attribute subcommand.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message = nil, subcommand: nil, stderr: nil, exit_code: nil, reason: nil) ⇒ CommandError
constructor
A new instance of CommandError.
Constructor Details
#initialize(message = nil, subcommand: nil, stderr: nil, exit_code: nil, reason: nil) ⇒ CommandError
Returns a new instance of CommandError.
22 23 24 25 26 27 28 |
# File 'lib/kube/errors.rb', line 22 def initialize( = nil, subcommand: nil, stderr: nil, exit_code: nil, reason: nil) @subcommand = subcommand @stderr = stderr @exit_code = exit_code @reason = reason || parse_reason(stderr) super( || ) end |
Instance Attribute Details
#exit_code ⇒ Object (readonly)
Returns the value of attribute exit_code.
20 21 22 |
# File 'lib/kube/errors.rb', line 20 def exit_code @exit_code end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
20 21 22 |
# File 'lib/kube/errors.rb', line 20 def reason @reason end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
20 21 22 |
# File 'lib/kube/errors.rb', line 20 def stderr @stderr end |
#subcommand ⇒ Object (readonly)
Returns the value of attribute subcommand.
20 21 22 |
# File 'lib/kube/errors.rb', line 20 def subcommand @subcommand end |
Class Method Details
.from_kubectl(subcommand:, stderr:, exit_code:) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/kube/errors.rb', line 30 def self.from_kubectl(subcommand:, stderr:, exit_code:) new( subcommand: subcommand, stderr: stderr, exit_code: exit_code ) end |