Hi everyone,
in our current project, we use Dry::Struct extensively. Our Dry::Structs are often nested (right now up to three levels). Here’s an example:
module Core
module Models
class Claim < Dry::Struct
attribute :policy, Core::Models::Policy
# ...
end
end
end
module Core
module Models
class Policy < Dry::Struct
# ...
end
end
end
When creating new instances of our structs, we often get this error:
Dry::Struct::MissingAttributeError:
Missing attribute: :transport
Due to the nesting, and the fact that we use Dry::Struct in many places (not just the model layer) it’s
often difficult to find out where the attribute is missing.
An improved exception message of Dry::Struct::MissingAttributeError would thus be (example):
Dry::Struct::MissingAttributeError:
Missing attribute: :transport on Core::Models::Claim
Here’s a PR to implement that: Add class name to MissingAttributeError exception message by phillipoertel · Pull Request #170 · dry-rb/dry-struct · GitHub.
We’d be happy if you find this addition helpful too.
Cheers
Phillip