Exception: NatureRemo::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/nature_remo/errors.rb

Overview

Error class for Nature Remo API

Direct Known Subclasses

ClientError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env:) ⇒ Error

Returns a new instance of Error.

Parameters:

  • env

    Faraday::Env



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/nature_remo/errors.rb', line 9

def initialize(env:)
  @env = env
  @url = env.url
  @status = env.status
  @headers = env.response_headers
  @body = env.body

  msg = "request failed with status code #{@status}"
  msg += ", #{@body}" if @body

  super(msg)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/nature_remo/errors.rb', line 6

def body
  @body
end

#envObject (readonly)

Returns the value of attribute env.



6
7
8
# File 'lib/nature_remo/errors.rb', line 6

def env
  @env
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



6
7
8
# File 'lib/nature_remo/errors.rb', line 6

def error_code
  @error_code
end

#headersObject (readonly)

Returns the value of attribute headers.



6
7
8
# File 'lib/nature_remo/errors.rb', line 6

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/nature_remo/errors.rb', line 6

def status
  @status
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/nature_remo/errors.rb', line 6

def url
  @url
end