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}"