lib/bright/errors.rb in bright-0.2.0 vs lib/bright/errors.rb in bright-1.0
- old
+ new
@@ -1,16 +1,26 @@
module Bright
class ResponseError < StandardError
attr_reader :response
+ attr_reader :uri
- def initialize(response, message = nil)
+ def initialize(response, uri = nil)
@response = response
- @message = message
+ @uri = uri
end
def to_s
- "Failed with #{response.code} #{response.message if response.respond_to?(:message)}"
+ "Failed with #{response.code} #{response.message if response.respond_to?(:message)}".strip
end
+
+ def body
+ response.body
+ end
+
+ def server_error?
+ (500..599).include?(response&.code.to_i)
+ end
+
end
class UnknownAttributeError < NoMethodError
attr_reader :record, :attribute