From 7de12091b0b3be559f2e083550b80b85ce82552f Mon Sep 17 00:00:00 2001 From: Andrzej Stencel Date: Tue, 24 Nov 2020 08:37:04 +0000 Subject: [PATCH] Fix `NoMethodError: undefined method `[]' for nil:NilClass` `@response` can be `nil`. --- lib/kubeclient/http_error.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kubeclient/http_error.rb b/lib/kubeclient/http_error.rb index fd49c2a5..a1bd6bea 100644 --- a/lib/kubeclient/http_error.rb +++ b/lib/kubeclient/http_error.rb @@ -15,7 +15,7 @@ def initialize(error_code, message, response) # rubocop:disable Lint/MissingSupe def to_s string = "HTTP status code #{@error_code}, #{@message}" - if @response[:request] + if @response && @response[:request] request_method = @response[:request][:method]&.to_s&.upcase request_path = @response[:request][:url_path] string += " for #{request_method} #{request_path}"