Exception: OpenFec::ClientError

Inherits:
Error
  • Object
show all
Defined in:
lib/open_fec/error.rb

Overview

Raised for 4xx HTTP responses.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, status: nil, body: nil) ⇒ ClientError

Returns a new instance of ClientError.

Parameters:

  • message (String, nil) (defaults to: nil)
  • status (Integer, nil) (defaults to: nil)
  • body (Hash, String, nil) (defaults to: nil)


17
18
19
20
21
# File 'lib/open_fec/error.rb', line 17

def initialize(message = nil, status: nil, body: nil)
  @status = status
  @body   = body
  super(message || "HTTP #{status}: #{body}")
end

Instance Attribute Details

#bodyHash, ... (readonly)

Returns response body.

Returns:

  • (Hash, String, nil)

    response body



12
13
14
# File 'lib/open_fec/error.rb', line 12

def body
  @body
end

#statusInteger? (readonly)

Returns HTTP status code.

Returns:

  • (Integer, nil)

    HTTP status code



10
11
12
# File 'lib/open_fec/error.rb', line 10

def status
  @status
end