Exception: MightyJSON::UnexpectedFieldError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/mighty_json/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, value:) ⇒ UnexpectedFieldError

Returns a new instance of UnexpectedFieldError.



34
35
36
37
# File 'lib/mighty_json/errors.rb', line 34

def initialize(path: , value:)
  @path = path
  @value = value
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



32
33
34
# File 'lib/mighty_json/errors.rb', line 32

def path
  @path
end

#valueObject (readonly)

Returns the value of attribute value.



32
33
34
# File 'lib/mighty_json/errors.rb', line 32

def value
  @value
end

Instance Method Details

#to_sObject Also known as: message



39
40
41
42
# File 'lib/mighty_json/errors.rb', line 39

def to_s
  position = "#{path.join('.')}"
  "Unexpected field of #{position} (#{value})"
end