Exception: Railsful::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Railsful::Error
- Defined in:
- lib/railsful/exceptions.rb
Overview
The base error for this gem.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#as_json(_options = nil) ⇒ Hash
Format the error as jsonapi wants it to.
-
#initialize(detail = nil, status = 400) ⇒ Error
constructor
Initializer.
Constructor Details
#initialize(detail = nil, status = 400) ⇒ Error
Initializer.
12 13 14 15 |
# File 'lib/railsful/exceptions.rb', line 12 def initialize(detail = nil, status = 400) @detail = detail @status = status end |
Instance Attribute Details
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
6 7 8 |
# File 'lib/railsful/exceptions.rb', line 6 def detail @detail end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/railsful/exceptions.rb', line 6 def status @status end |
Instance Method Details
#as_json(_options = nil) ⇒ Hash
Format the error as jsonapi wants it to.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/railsful/exceptions.rb', line 20 def as_json( = nil) { errors: [ { status: status, title: self.class.name.demodulize.underscore, detail: detail } ] } end |