Exception: SolscanApiRuby::Client::ApiError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/solscan_api_ruby/client/api_error.rb

Overview

ApiError is a wrapper class for errors.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_response) ⇒ SolscanApiRuby::Client::ApiError

Initialize object with json response from the API with error.

Parameters:

  • api_response (Object)


22
23
24
25
26
27
28
29
30
# File 'lib/solscan_api_ruby/client/api_error.rb', line 22

def initialize(api_response)
  body = Oj.load(api_response.body)

  @error = body['error']
  @status = body['status']
rescue Oj::ParseError
  @error = api_response.body
  @status = api_response.status
end

Instance Attribute Details

#errorHash (readonly)

Error message.

Returns:

  • (Hash)


15
16
17
# File 'lib/solscan_api_ruby/client/api_error.rb', line 15

def error
  @error
end

#statusInteger (readonly)

Error code.

Returns:

  • (Integer)


11
12
13
# File 'lib/solscan_api_ruby/client/api_error.rb', line 11

def status
  @status
end