Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 116814
Status: resolved
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: GFISH [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.1804
Fixed in: 2.1806



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.
On 2016-08-09 21:01:20, GFISH wrote: Show quoted text
> 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.
I agree. Are you interested in submitting a patch? The error comes from one of the Moose::Exception:: classes.
On Wed Aug 10 14:39:34 2016, ETHER wrote: Show quoted text
> On 2016-08-09 21:01:20, GFISH wrote:
> > 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.
> > I agree. > > Are you interested in submitting a patch? The error comes from one of > the Moose::Exception:: classes.
Sure, when I get some time to look through that.
On 2016-09-11 09:33:03, DROLSKY wrote: Show quoted text
This is merged and will be in 2.1806.