Exception: Bright::ResponseError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, uri = nil) ⇒ ResponseError

Returns a new instance of ResponseError.



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

def initialize(response, uri = nil)
  @response = response
  @uri = uri
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/bright/errors.rb', line 3

def response
  @response
end

#uriObject (readonly)

Returns the value of attribute uri.



4
5
6
# File 'lib/bright/errors.rb', line 4

def uri
  @uri
end

Instance Method Details

#bodyObject



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

def body
  response.body
end

#server_error?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/bright/errors.rb', line 19

def server_error?
  (500..599).include?(response&.code.to_i)
end

#to_sObject



11
12
13
# File 'lib/bright/errors.rb', line 11

def to_s
  "Failed with #{response.code} #{response.message if response.respond_to?(:message)}".strip
end