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.



36
37
38
39
# File 'lib/mighty_json/errors.rb', line 36

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

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#to_sObject Also known as: message



41
42
43
44
# File 'lib/mighty_json/errors.rb', line 41

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