Exception: Avski::Common::Exceptions::UnknownFieldException

Inherits:
StandardError
  • Object
show all
Defined in:
lib/avski/common/exceptions.rb

Direct Known Subclasses

EmptyFieldException, NullFieldException

Instance Attribute Summary collapse

Instance Method Summary collapse

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(message, status = 400, code = 0, data = {})
  @status = status
  @message = message
  @data = data
  @code = code
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



9
10
11
# File 'lib/avski/common/exceptions.rb', line 9

def code
  @code
end

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/avski/common/exceptions.rb', line 9

def data
  @data
end

#messageObject (readonly)

Returns the value of attribute message.



9
10
11
# File 'lib/avski/common/exceptions.rb', line 9

def message
  @message
end

#statusObject (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_hashObject



25
26
27
# File 'lib/avski/common/exceptions.rb', line 25

def to_hash
  {status: @status, message: @message, code: @code, data: @data}
end

#to_jsonObject

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_responseObject



29
30
31
# File 'lib/avski/common/exceptions.rb', line 29

def to_response
  [@status, to_json]
end