Exception: RocketPants::Error
- Inherits:
-
StandardError
- Object
- StandardError
- RocketPants::Error
- Defined in:
- lib/rocket_pants/error.rb
Overview
Represents the standard error type as defined by the API. RocketPants::Error instances will be caught and automatically rendered as JSON by the controller during processing.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#context ⇒ Hash
Gets the context for this error, defaulting to nil.
Class Method Summary collapse
Instance Method Summary collapse
-
#error_name ⇒ Object
Gets the name of this error from the class.
-
#http_status ⇒ Object
Gets the http status of this error from the class.
Instance Attribute Details
#context ⇒ Hash
Gets the context for this error, defaulting to nil.
51 52 53 |
# File 'lib/rocket_pants/error.rb', line 51 def context @context ||= {} end |
Class Method Details
.error_name ⇒ Symbol .error_name(value) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rocket_pants/error.rb', line 15 def self.error_name(value = nil) if value.nil? @name ||= name.underscore.split("/").last.sub(/_error$/, '').to_sym else @name = (value.presence && value.to_sym) end end |
.http_status ⇒ Object .http_status(value) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/rocket_pants/error.rb', line 28 def self.http_status(value = nil) if value.nil? @http_status ||= 400 else @http_status = (value.presence && value) end end |
Instance Method Details
#error_name ⇒ Object
Gets the name of this error from the class.
37 38 39 |
# File 'lib/rocket_pants/error.rb', line 37 def error_name self.class.error_name end |
#http_status ⇒ Object
Gets the http status of this error from the class.
42 43 44 |
# File 'lib/rocket_pants/error.rb', line 42 def http_status self.class.http_status end |