Exception: CirroIOV2::Errors::ClientError

Inherits:
StandardError
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/cirro_io_v2/errors/client_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(faraday_error) ⇒ ClientError

this error class is intended to be used ONLY for 4xx errors www.rubydoc.info/github/lostisland/faraday/Faraday/ClientError



15
16
17
# File 'lib/cirro_io_v2/errors/client_error.rb', line 15

def initialize(faraday_error)
  @faraday_error = faraday_error
end

Instance Attribute Details

#faraday_errorObject (readonly)

Returns the value of attribute faraday_error.



10
11
12
# File 'lib/cirro_io_v2/errors/client_error.rb', line 10

def faraday_error
  @faraday_error
end

Instance Method Details

#messageObject



19
20
21
22
23
24
25
# File 'lib/cirro_io_v2/errors/client_error.rb', line 19

def message
  return faraday_error.response.inspect if ENV['DEBUG_CIRRO_RUBY_CLIENT']

  body = faraday_error.response&.dig(:body)
  result = body.presence || faraday_error.try(:message)
  result.is_a?(String) ? result : result.to_json
end