Exception: Avski::Common::Exceptions::UnknownFieldException
- Inherits:
-
StandardError
- Object
- StandardError
- Avski::Common::Exceptions::UnknownFieldException
- Defined in:
- lib/avski/common/exceptions.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(message, status = 400, code = 0, data = {}) ⇒ UnknownFieldException
constructor
A new instance of UnknownFieldException.
- #to_hash ⇒ Object
-
#to_json ⇒ Object
Convert Exception contents to a Json string.
- #to_response ⇒ Object
Constructor Details
#initialize(message, status = 400, code = 0, data = {}) ⇒ UnknownFieldException
Returns a new instance of UnknownFieldException.
11 12 13 14 15 16 |
# File 'lib/avski/common/exceptions.rb', line 11 def initialize(, status = 400, code = 0, data = {}) @status = status @message = @data = data @code = code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
9 10 11 |
# File 'lib/avski/common/exceptions.rb', line 9 def code @code end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/avski/common/exceptions.rb', line 9 def data @data end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
9 10 11 |
# File 'lib/avski/common/exceptions.rb', line 9 def @message end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/avski/common/exceptions.rb', line 9 def status @status end |
Instance Method Details
#to_hash ⇒ Object
25 26 27 |
# File 'lib/avski/common/exceptions.rb', line 25 def to_hash {status: @status, message: @message, code: @code, data: @data} end |
#to_json ⇒ Object
Convert Exception contents to a Json string. All attributes must be Json serializable.
21 22 23 |
# File 'lib/avski/common/exceptions.rb', line 21 def to_json JSON.generate(to_hash) end |
#to_response ⇒ Object
29 30 31 |
# File 'lib/avski/common/exceptions.rb', line 29 def to_response [@status, to_json] end |