Exception: Served::Resource::HttpError
- Inherits:
-
Error
- Object
- StandardError
- Base::ServiceError
- Error
- Served::Resource::HttpError
- Defined in:
- lib/served/resource/http_errors.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#server_backtrace ⇒ Object
readonly
Returns the value of attribute server_backtrace.
Instance Method Summary collapse
-
#initialize(code, resource, response) ⇒ HttpError
constructor
A new instance of HttpError.
- #status ⇒ Object
Constructor Details
#initialize(code, resource, response) ⇒ HttpError
Returns a new instance of HttpError.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/served/resource/http_errors.rb', line 10 def initialize(code, resource, response) @code = code if resource.serializer.respond_to? :exception serialized = resource.serializer.exception(response.body).symbolize_keys! @error = serialized[:error] @message = serialized[:exception] @server_backtrace = serialized[:backtrace] @response = OpenStruct.new(serialized) # TODO: remove in served 1.0, used for backwards compat super("An error '#{code} #{}' occurred while making this request") else super "An error occurred '#{code}'" end end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/served/resource/http_errors.rb', line 8 def code @code end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/served/resource/http_errors.rb', line 6 def errors @errors end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
4 5 6 |
# File 'lib/served/resource/http_errors.rb', line 4 def @message end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
7 8 9 |
# File 'lib/served/resource/http_errors.rb', line 7 def response @response end |
#server_backtrace ⇒ Object (readonly)
Returns the value of attribute server_backtrace.
5 6 7 |
# File 'lib/served/resource/http_errors.rb', line 5 def server_backtrace @server_backtrace end |
Instance Method Details
#status ⇒ Object
27 28 29 |
# File 'lib/served/resource/http_errors.rb', line 27 def status self.class.status end |