Skip to content

Set JSON::SerializableError#attribute when attribute is missing during parsing #16156

@spuun

Description

@spuun

#attribute isn't set in JSON::SerializableError when an attribute is missing in json:

require "json"

struct Foo
  include ::JSON::Serializable
  def initialize(@name : String)
  end
end

begin
Foo.from_json %({})
rescue e : ::JSON::SerializableError
	pp e.attribute # => nil
end

Any reason for it not to be set? It's included in the message.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions