Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

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

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

Bug Information
Severity: (no value)
Broken in: 2.1204
Fixed in: 2.1205



Subject: Confusing error message when trying to load a trait class that does not exist in @INC
When trying to load a trait class that does not exist in @INC, Moose throws the following exception: Attribute (type) does not pass the type constraint because: Validation failed for 'Moose::Meta::TypeConstraint' with value Attribute (not isa Moose::Meta::TypeConstraint) at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Exception.pm line 37 Moose::Exception::_build_trace('Moose::Exception::ValidationFailedForTypeConstraint=HASH(0x249af58)') called at reader Moose::Exception::trace (defined at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Exception.pm line 9) line 7 Moose::Exception::trace('Moose::Exception::ValidationFailedForTypeConstraint=HASH(0x249af58)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Exception.pm line 49 Moose::Exception::BUILD('Moose::Exception::ValidationFailedForTypeConstraint=HASH(0x249af58)', 'HASH(0x24805a0)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Class/MOP/Method.pm line 128 Class::MOP::Method::execute('Moose::Meta::Method=HASH(0x24c05d0)', 'Moose::Exception::ValidationFailedForTypeConstraint=HASH(0x249af58)', 'HASH(0x24805a0)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Object.pm line 56 Moose::Object::BUILDALL('Moose::Exception::ValidationFailedForTypeConstraint=HASH(0x249af58)', 'HASH(0x24805a0)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Meta/Class.pm line 282 Moose::Meta::Class::new_object('Moose::Meta::Class=HASH(0x257bf60)', 'HASH(0x24805a0)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Object.pm line 27 Moose::Object::new('Moose::Exception::ValidationFailedForTypeConstraint', 'type', 'Moose::Meta::TypeConstraint::Class=HASH(0x24d1cc8)', 'value', 'Attribute', 'attribute', 'Moose::Meta::Attribute=HASH(0x24c38a8)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Util.pm line 51 Moose::Util::throw_exception('ValidationFailedForTypeConstraint', 'type', 'Moose::Meta::TypeConstraint::Class=HASH(0x24d1cc8)', 'value', 'Attribute', 'attribute', 'Moose::Meta::Attribute=HASH(0x24c38a8)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Meta/Attribute.pm line 1267 Moose::Meta::Attribute::verify_against_type_constraint('Moose::Meta::Attribute=HASH(0x24c38a8)', 'Attribute', 'instance', 'Moose::Exception::CannotLocatePackageInINC=HASH(0x19a2b70)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Meta/Attribute.pm line 1254 Moose::Meta::Attribute::_coerce_and_verify('Moose::Meta::Attribute=HASH(0x24c38a8)', 'Attribute', 'Moose::Exception::CannotLocatePackageInINC=HASH(0x19a2b70)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Meta/Attribute.pm line 514 Moose::Meta::Attribute::initialize_instance_slot('Moose::Meta::Attribute=HASH(0x24c38a8)', 'Moose::Meta::Instance=HASH(0x2565aa0)', 'Moose::Exception::CannotLocatePackageInINC=HASH(0x19a2b70)', 'HASH(0x19981b8)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Class/MOP/Class.pm line 529 Class::MOP::Class::_construct_instance('Moose::Meta::Class=HASH(0x24ae938)', 'HASH(0x19981b8)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Class/MOP/Class.pm line 499 Class::MOP::Class::new_object('Moose::Meta::Class=HASH(0x24ae938)', 'HASH(0x19981b8)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Meta/Class.pm line 278 Moose::Meta::Class::new_object('Moose::Meta::Class=HASH(0x24ae938)', 'HASH(0x19981b8)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Object.pm line 27 Moose::Object::new('Moose::Exception::CannotLocatePackageInINC', 'possible_packages', 'MISSING_TRAIT or Moose::Meta::Attribute::Custom::Trait::MISSING_TRAIT', 'INC', 'ARRAY(0x196dcc8)', 'type', 'Attribute', 'metaclass_name', 'MISSING_TRAIT', 'params', 'HASH(0x1be66a8)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Util.pm line 51 Moose::Util::throw_exception('CannotLocatePackageInINC', 'possible_packages', 'MISSING_TRAIT or Moose::Meta::Attribute::Custom::Trait::MISSING_TRAIT', 'INC', 'ARRAY(0x196dcc8)', 'type', 'Attribute', 'metaclass_name', 'MISSING_TRAIT', 'params', 'HASH(0x1be66a8)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Util.pm line 243 Moose::Util::resolve_metaclass_alias('Attribute', 'MISSING_TRAIT', 'trait', 1) called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Util.pm line 205 Moose::Util::resolve_metatrait_alias('Attribute', 'MISSING_TRAIT') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Meta/Attribute.pm line 131 Moose::Meta::Attribute::interpolate_class('Moose::Meta::Attribute', 'HASH(0x2003138)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Meta/Attribute.pm line 100 Moose::Meta::Attribute::interpolate_class_and_new('Moose::Meta::Attribute', 'attr', 'definition_context', 'HASH(0x19b0d20)', 'traits', 'ARRAY(0x196dde8)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Meta/Class.pm line 716 Moose::Meta::Class::_process_new_attribute('Moose::Meta::Class=HASH(0x1998698)', 'attr', 'definition_context', 'HASH(0x19b0d20)', 'traits', 'ARRAY(0x196dde8)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Meta/Class.pm line 709 Moose::Meta::Class::_process_attribute('Moose::Meta::Class=HASH(0x1998698)', 'attr', 'definition_context', 'HASH(0x19b0d20)', 'traits', 'ARRAY(0x196dde8)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Meta/Class.pm line 573 Moose::Meta::Class::add_attribute('Moose::Meta::Class=HASH(0x1998698)', 'attr', 'definition_context', 'HASH(0x19b0d20)', 'traits', 'ARRAY(0x196dde8)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose.pm line 77 Moose::has('Moose::Meta::Class=HASH(0x1998698)', 'attr', 'traits', 'ARRAY(0x196dde8)') called at /home/nbkyslo/perl5/lib/perl5/x86_64-linux/Moose/Exporter.pm line 405 Moose::has('attr', 'traits', 'ARRAY(0x196dde8)') called at test-moose-missing-trait.pl line 4 It looks like the right exception (Moose::Exception::CannotLocatePackageInINC) is attempting to be thrown, but there's a problem when trying to construct the exception object. Sample code that produces this error message: { package My::Class; use Moose; has 'attr' => ( traits => [qw( MISSING_TRAIT )] ); } use My::Class; My::Class->new;
This is now fixed in the master branch via https://github.com/moose/Moose/pull/63 (thanks, Upasana!)
2.1205 has been shipped.