Subject: | Missing required atttribute in constructor error message doesn't mention init_arg name. |
I have noticed that when a required attribute is omitted from the constructor, and that attribute has init_arg defined, the error message that is issued makes no mention of said init_arg.
This would seem to be misleading.
If an attribute is defined like follows:
has some_foo' => ( ..., init_arg => 'foo', required => 1 );
And one tries to instantiate the class with this required attribute, the following error is displayed:
Attribute (some_foo) is required at constructor My::Class::new
So a user with no knowledge of the inner workings of this class would logically attempt to use My::Class::new(some_foo => ...) only to still have it die again with the same message.
When an init_arg is defined for an attribute, would it not make more sense to include that name, seeing as the message is pertaining to the constructor? Like something perhaps along the lines of:
Attribute (some_foo), as (foo), is required at constructor My::Class::new
And for what it's worth I'm hesitant to call this a bug per-se, but rather a suggestion on how an otherwise wonderful module library could be improved in one specific place. I of course welcome any insights, counter-suggestions, and criticisms as well.