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
BadGateway, BadRequest, Forbidden, InternalServerError, MethodNotAllowed, MovedPermanently, NotAcceptable, NotFound, RequestTimeout, Unauthorized, UnprocessableEntity
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.
Class Method Summary collapse
-
.code ⇒ Object
Defined in individual error classes.
Instance Method Summary collapse
-
#initialize(resource, response) ⇒ HttpError
constructor
A new instance of HttpError.
- #status ⇒ Object
Constructor Details
#initialize(resource, response) ⇒ HttpError
Returns a new instance of HttpError.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/served/resource/http_errors.rb', line 15 def initialize(resource, response) if resource.serializer.respond_to? :exception serialized = resource.serializer.exception(response.body).symbolize_keys! @error = serialized[:error] @message = serialized[:exception] @server_backtrace = serialized[:backtrace] @code = serialized[:code] || serialized[:code] = self.class.code @response = OpenStruct.new(serialized) # TODO: remove in served 1.0, used for backwards compat super("An error '#{code} #{}' occurred while making this request") end super "An error occurred '#{self.class.code}'" 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 |
Class Method Details
.code ⇒ Object
Defined in individual error classes
11 12 13 |
# File 'lib/served/resource/http_errors.rb', line 11 def self.code raise NotImplementedError end |
Instance Method Details
#status ⇒ Object
30 31 32 |
# File 'lib/served/resource/http_errors.rb', line 30 def status self.class.status end |