I've encountered an unexpected behavior when trying to raise Oktakit::Error.from_response(response) causing TypeError - exception object expected with oktakit version 0.3.1.
###
response = {:errorCode=>"E0000007", :errorSummary=> "Not found: Resource not found: abrakadabrasdfskdkf@admin.com (User)", :errorLink=>"E0000007", :errorId=>"oaeLRic8zbhTBiJ81eJnWTQUg", :errorCauses=>[]}
###
# lib/oktakit/error.rb
module Oktakit
# Custom error class for rescuing from all Okta errors
class Error < StandardError
# Returns the appropriate Oktakit::Error subclass based
# on status and response message
#
# @param [Hash] response HTTP response
# @return [Oktakit::Error]
def self.from_response(response)
status = response[:status].to_i # nil.to_i = 0
if (klass = error(status)) # this block returns nil
klass.new(response)
end
end
...
def build_error_message
return nil if @response.nil?
message = "#{@response[:method].to_s.upcase} " # no corresponding attribute
message << redact_url(@response[:url].to_s) + ': ' # same here
message << "#{@response[:status]} - " # and same here
message << response_message.to_s unless response_message.nil?
message
end
...
It looks like the structure of the response object for errors has changed (documentation link).
Hi there,
I've encountered an unexpected behavior when trying to raise
Oktakit::Error.from_response(response)
causingTypeError - exception object expected
withoktakit
version 0.3.1.Steps to reproduce
It looks like the structure of the response object for errors has changed (documentation link).