2 package Moose::Meta::Class;
7 use Class::Load qw(load_class);
9 use Carp qw( confess );
11 use List::Util qw( first );
12 use List::MoreUtils qw( any all uniq first_index );
13 use Scalar::Util 'blessed';
15 use Moose::Meta::Method::Overridden;
16 use Moose::Meta::Method::Augmented;
17 use Moose::Error::Default;
18 use Moose::Meta::Class::Immutable::Trait;
19 use Moose::Meta::Method::Constructor;
20 use Moose::Meta::Method::Destructor;
21 use Moose::Meta::Method::Meta;
24 use base 'Class::MOP::Class';
26 __PACKAGE__->meta->add_attribute('roles' => (
28 default => sub { [] },
29 Class::MOP::_definition_context(),
32 __PACKAGE__->meta->add_attribute('role_applications' => (
33 reader => '_get_role_applications',
34 default => sub { [] },
35 Class::MOP::_definition_context(),
38 __PACKAGE__->meta->add_attribute(
39 Class::MOP::Attribute->new('immutable_trait' => (
40 accessor => "immutable_trait",
41 default => 'Moose::Meta::Class::Immutable::Trait',
42 Class::MOP::_definition_context(),
46 __PACKAGE__->meta->add_attribute('constructor_class' => (
47 accessor => 'constructor_class',
48 default => 'Moose::Meta::Method::Constructor',
49 Class::MOP::_definition_context(),
52 __PACKAGE__->meta->add_attribute('destructor_class' => (
53 accessor => 'destructor_class',
54 default => 'Moose::Meta::Method::Destructor',
55 Class::MOP::_definition_context(),
58 __PACKAGE__->meta->add_attribute('error_class' => (
59 accessor => 'error_class',
60 default => 'Moose::Error::Default',
61 Class::MOP::_definition_context(),
67 unshift @args, 'package' if @args % 2;
69 my $package = delete $opts{package};
70 return Class::MOP::get_metaclass_by_name($package)
71 || $class->SUPER::initialize($package,
72 'attribute_metaclass' => 'Moose::Meta::Attribute',
73 'method_metaclass' => 'Moose::Meta::Method',
74 'instance_metaclass' => 'Moose::Meta::Instance',
83 unshift @args, 'package' if @args % 2 == 1;
86 (ref $options{roles} eq 'ARRAY')
87 || $class->throw_error("You must pass an ARRAY ref of roles", data => $options{roles})
88 if exists $options{roles};
90 my $package = delete $options{package};
91 my $roles = delete $options{roles};
93 my $new_meta = $class->SUPER::create($package, %options);
96 Moose::Util::apply_all_roles( $new_meta, @$roles );
102 sub _meta_method_class { 'Moose::Meta::Method::Meta' }
104 sub _anon_package_prefix { 'Moose::Meta::Class::__ANON__::SERIAL::' }
106 sub _anon_cache_key {
110 my $superclass_key = join('|',
111 map { $_->[0] } @{ Data::OptList::mkopt($options{superclasses} || []) }
114 my $roles = Data::OptList::mkopt(($options{roles} || []), {
116 val_test => sub { ref($_[0]) eq 'HASH' },
120 for my $role_spec (@$roles) {
121 my ($role, $params) = @$role_spec;
122 $params = { %$params } if $params;
124 my $key = blessed($role) ? $role->name : $role;
126 if ($params && %$params) {
127 my $alias = delete $params->{'-alias'}
128 || delete $params->{'alias'}
130 my $excludes = delete $params->{'-excludes'}
131 || delete $params->{'excludes'}
133 $excludes = [$excludes] unless ref($excludes) eq 'ARRAY';
136 warn "Roles with parameters cannot be cached. Consider "
137 . "applying the parameters before calling "
138 . "create_anon_class, or using 'weaken => 0' instead";
142 my $alias_key = join('%',
143 map { $_ => $alias->{$_} } sort keys %$alias
145 my $excludes_key = join('%',
148 $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>';
151 push @role_keys, $key;
154 my $role_key = join('|', sort @role_keys);
156 # Makes something like Super::Class|Super::Class::2=Role|Role::1
157 return join('=', $superclass_key, $role_key);
164 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
166 my %existing_classes;
168 %existing_classes = map { $_ => $meta->$_() } qw(
171 wrapped_method_metaclass
179 return $self->SUPER::reinitialize(
187 my ($self, $role) = @_;
188 (blessed($role) && $role->isa('Moose::Meta::Role'))
189 || $self->throw_error("Roles must be instances of Moose::Meta::Role", data => $role);
190 push @{$self->roles} => $role;
193 sub role_applications {
196 return @{$self->_get_role_applications};
199 sub add_role_application {
200 my ($self, $application) = @_;
201 (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass'))
202 || $self->throw_error("Role applications must be instances of Moose::Meta::Role::Application::ToClass", data => $application);
203 push @{$self->_get_role_applications} => $application;
206 sub calculate_all_roles {
209 grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles };
212 sub calculate_all_roles_with_inheritance {
215 grep { !$seen{$_->name}++ }
216 map { Class::MOP::class_of($_)->can('calculate_all_roles')
217 ? Class::MOP::class_of($_)->calculate_all_roles
219 $self->linearized_isa;
223 my ($self, $role_name) = @_;
226 || $self->throw_error("You must supply a role name to look for");
228 foreach my $class ($self->class_precedence_list) {
229 my $meta = Class::MOP::class_of($class);
230 # when a Moose metaclass is itself extended with a role,
231 # this check needs to be done since some items in the
232 # class_precedence_list might in fact be Class::MOP
234 next unless $meta && $meta->can('roles');
235 foreach my $role (@{$meta->roles}) {
236 return 1 if $role->does_role($role_name);
243 my ($self, $role_name) = @_;
246 || $self->throw_error("You must supply a role name to look for");
248 foreach my $class ($self->class_precedence_list) {
249 my $meta = Class::MOP::class_of($class);
250 # when a Moose metaclass is itself extended with a role,
251 # this check needs to be done since some items in the
252 # class_precedence_list might in fact be Class::MOP
254 next unless $meta && $meta->can('roles');
255 foreach my $role (@{$meta->roles}) {
256 return 1 if $role->excludes_role($role_name);
264 my $params = @_ == 1 ? $_[0] : {@_};
265 my $object = $self->SUPER::new_object($params);
267 $self->_call_all_triggers($object, $params);
269 $object->BUILDALL($params) if $object->can('BUILDALL');
274 sub _call_all_triggers {
275 my ($self, $object, $params) = @_;
277 foreach my $attr ( $self->get_all_attributes() ) {
279 next unless $attr->can('has_trigger') && $attr->has_trigger;
281 my $init_arg = $attr->init_arg;
282 next unless defined $init_arg;
283 next unless exists $params->{$init_arg};
289 ? $attr->get_read_method_ref->($object)
290 : $params->{$init_arg}
296 sub _generate_fallback_constructor {
299 return $class . '->Moose::Object::new(@_)'
304 my ($params, $class) = @_;
306 'my ' . $params . ' = ',
307 $self->_inline_BUILDARGS($class, '@_'),
312 sub _inline_BUILDARGS {
314 my ($class, $args) = @_;
316 my $buildargs = $self->find_method_by_name("BUILDARGS");
319 && (!$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS)) {
323 'if (scalar @_ == 1) {',
324 'if (!defined($_[0]) || ref($_[0]) ne \'HASH\') {',
325 $self->_inline_throw_error(
326 '"Single parameters to new() must be a HASH ref"',
330 '$params = { %{ $_[0] } };',
334 '"The new() method for ' . $class . ' expects a '
335 . 'hash reference or a key/value list. You passed an '
336 . 'odd number of arguments"',
338 '$params = {@_, undef};',
348 return $class . '->BUILDARGS(' . $args . ')';
352 sub _inline_slot_initializer {
354 my ($attr, $idx) = @_;
358 $self->_inline_check_required_attr($attr),
359 $self->SUPER::_inline_slot_initializer(@_),
363 sub _inline_check_required_attr {
367 return unless defined $attr->init_arg;
368 return unless $attr->can('is_required') && $attr->is_required;
369 return if $attr->has_default || $attr->has_builder;
372 'if (!exists $params->{\'' . $attr->init_arg . '\'}) {',
373 $self->_inline_throw_error(
374 '"Attribute (' . quotemeta($attr->name) . ') is required"'
380 # XXX: these two are duplicated from cmop, because we have to pass the tc stuff
381 # through to _inline_set_value - this should probably be fixed, but i'm not
382 # quite sure how. -doy
383 sub _inline_init_attr_from_constructor {
385 my ($attr, $idx) = @_;
387 my @initial_value = $attr->_inline_set_value(
389 '$params->{\'' . $attr->init_arg . '\'}',
390 '$type_constraint_bodies[' . $idx . ']',
391 '$type_coercions[' . $idx . ']',
392 '$type_constraint_messages[' . $idx . ']',
396 push @initial_value, (
397 '$attrs->[' . $idx . ']->set_initial_value(',
399 $attr->_inline_instance_get('$instance'),
401 ) if $attr->has_initializer;
403 return @initial_value;
406 sub _inline_init_attr_from_default {
408 my ($attr, $idx) = @_;
410 return if $attr->can('is_lazy') && $attr->is_lazy;
411 my $default = $self->_inline_default_value($attr, $idx);
412 return unless $default;
414 my @initial_value = (
415 'my $default = ' . $default . ';',
416 $attr->_inline_set_value(
419 '$type_constraint_bodies[' . $idx . ']',
420 '$type_coercions[' . $idx . ']',
421 '$type_constraint_messages[' . $idx . ']',
426 push @initial_value, (
427 '$attrs->[' . $idx . ']->set_initial_value(',
429 $attr->_inline_instance_get('$instance'),
431 ) if $attr->has_initializer;
433 return @initial_value;
436 sub _inline_extra_init {
439 $self->_inline_triggers,
440 $self->_inline_BUILDALL,
444 sub _inline_triggers {
448 my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
449 for my $i (0 .. $#attrs) {
450 my $attr = $attrs[$i];
452 next unless $attr->can('has_trigger') && $attr->has_trigger;
454 my $init_arg = $attr->init_arg;
455 next unless defined $init_arg;
458 'if (exists $params->{\'' . $init_arg . '\'}) {',
459 '$triggers->[' . $i . ']->(',
461 $attr->_inline_instance_get('$instance') . ',',
466 return @trigger_calls;
469 sub _inline_BUILDALL {
472 my @methods = reverse $self->find_all_methods_by_name('BUILD');
475 foreach my $method (@methods) {
477 '$instance->' . $method->{class} . '::BUILD($params);';
483 sub _eval_environment {
486 my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
489 map { $_->can('has_trigger') && $_->has_trigger ? $_->trigger : undef }
493 # We need to check if the attribute ->can('type_constraint')
494 # since we may be trying to immutabilize a Moose meta class,
495 # which in turn has attributes which are Class::MOP::Attribute
496 # objects, rather than Moose::Meta::Attribute. And
497 # Class::MOP::Attribute attributes have no type constraints.
498 # However we need to make sure we leave an undef value there
499 # because the inlined code is using the index of the attributes
500 # to determine where to find the type constraint
502 my @type_constraints = map {
503 $_->can('type_constraint') ? $_->type_constraint : undef
506 my @type_constraint_bodies = map {
507 defined $_ ? $_->_compiled_type_constraint : undef;
510 my @type_coercions = map {
511 defined $_ && $_->has_coercion
512 ? $_->coercion->_compiled_type_coercion
516 my @type_constraint_messages = map {
518 ? ($_->has_message ? $_->message : $_->_default_message)
523 %{ $self->SUPER::_eval_environment },
524 ((any { defined && $_->has_initializer } @attrs)
525 ? ('$attrs' => \[@attrs])
527 '$triggers' => \$triggers,
528 '@type_coercions' => \@type_coercions,
529 '@type_constraint_bodies' => \@type_constraint_bodies,
530 '@type_constraint_messages' => \@type_constraint_messages,
531 ( map { defined($_) ? %{ $_->inline_environment } : () }
533 # pretty sure this is only going to be closed over if you use a custom
534 # error class at this point, but we should still get rid of this
542 my $supers = Data::OptList::mkopt(\@_);
543 foreach my $super (@{ $supers }) {
544 my ($name, $opts) = @{ $super };
545 load_class($name, $opts);
546 my $meta = Class::MOP::class_of($name);
547 $self->throw_error("You cannot inherit from a Moose Role ($name)")
548 if $meta && $meta->isa('Moose::Meta::Role')
550 return $self->SUPER::superclasses(map { $_->[0] } @{ $supers });
553 ### ---------------------------------------------
558 (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute')
560 : $self->_process_attribute(@_));
561 $self->SUPER::add_attribute($attr);
562 # it may be a Class::MOP::Attribute, theoretically, which doesn't have
563 # 'bare' and doesn't implement this method
564 if ($attr->can('_check_associated_methods')) {
565 $attr->_check_associated_methods;
570 sub add_override_method_modifier {
571 my ($self, $name, $method, $_super_package) = @_;
573 (!$self->has_method($name))
574 || $self->throw_error("Cannot add an override method if a local method is already present");
576 $self->add_method($name => Moose::Meta::Method::Overridden->new(
579 package => $_super_package, # need this for roles
584 sub add_augment_method_modifier {
585 my ($self, $name, $method) = @_;
586 (!$self->has_method($name))
587 || $self->throw_error("Cannot add an augment method if a local method is already present");
589 $self->add_method($name => Moose::Meta::Method::Augmented->new(
596 ## Private Utility methods ...
598 sub _find_next_method_by_name_which_is_not_overridden {
599 my ($self, $name) = @_;
600 foreach my $method ($self->find_all_methods_by_name($name)) {
601 return $method->{code}
602 if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden');
607 ## Metaclass compatibility
609 sub _base_metaclasses {
611 my %metaclasses = $self->SUPER::_base_metaclasses;
612 for my $class (keys %metaclasses) {
613 $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/;
617 error_class => 'Moose::Error::Default',
621 sub _fix_class_metaclass_incompatibility {
623 my ($super_meta) = @_;
625 $self->SUPER::_fix_class_metaclass_incompatibility(@_);
627 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
629 || confess "Can't fix metaclass incompatibility for "
631 . " because it is not pristine.";
632 my $super_meta_name = $super_meta->_real_ref_name;
633 my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name);
634 my $new_self = $class_meta_subclass_meta_name->reinitialize(
638 $self->_replace_self( $new_self, $class_meta_subclass_meta_name );
642 sub _fix_single_metaclass_incompatibility {
644 my ($metaclass_type, $super_meta) = @_;
646 $self->SUPER::_fix_single_metaclass_incompatibility(@_);
648 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
650 || confess "Can't fix metaclass incompatibility for "
652 . " because it is not pristine.";
653 my $super_meta_name = $super_meta->_real_ref_name;
654 my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type);
655 my $new_self = $super_meta->reinitialize(
657 $metaclass_type => $class_specific_meta_subclass_meta_name,
660 $self->_replace_self( $new_self, $super_meta_name );
666 my ( $new_self, $new_class) = @_;
669 bless $self, $new_class;
671 # We need to replace the cached metaclass instance or else when it goes
672 # out of scope Class::MOP::Class destroy's the namespace for the
673 # metaclass's class, causing much havoc.
674 my $weaken = Class::MOP::metaclass_is_weak( $self->name );
675 Class::MOP::store_metaclass_by_name( $self->name, $self );
676 Class::MOP::weaken_metaclass( $self->name ) if $weaken;
679 sub _process_attribute {
680 my ( $self, $name, @args ) = @_;
682 @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH';
684 if (($name || '') =~ /^\+(.*)/) {
685 return $self->_process_inherited_attribute($1, @args);
688 return $self->_process_new_attribute($name, @args);
692 sub _process_new_attribute {
693 my ( $self, $name, @args ) = @_;
695 $self->attribute_metaclass->interpolate_class_and_new($name, @args);
698 sub _process_inherited_attribute {
699 my ($self, $attr_name, %options) = @_;
700 my $inherited_attr = $self->find_attribute_by_name($attr_name);
701 (defined $inherited_attr)
702 || $self->throw_error("Could not find an attribute by the name of '$attr_name' to inherit from in ${\$self->name}", data => $attr_name);
703 if ($inherited_attr->isa('Moose::Meta::Attribute')) {
704 return $inherited_attr->clone_and_inherit_options(%options);
708 # kind of a kludge to handle Class::MOP::Attributes
709 return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options);
713 # reinitialization support
715 sub _restore_metaobjects_from {
719 $self->SUPER::_restore_metaobjects_from($old_meta);
721 for my $role ( @{ $old_meta->roles } ) {
722 $self->add_role($role);
725 for my $application ( @{ $old_meta->_get_role_applications } ) {
726 $application->class($self);
727 $self->add_role_application ($application);
733 sub _immutable_options {
734 my ( $self, @args ) = @_;
736 $self->SUPER::_immutable_options(
737 inline_destructor => 1,
739 # Moose always does this when an attribute is created
740 inline_accessors => 0,
746 sub _fixup_attributes_after_rebless {
748 my ($instance, $rebless_from, %params) = @_;
750 $self->SUPER::_fixup_attributes_after_rebless(
756 $self->_call_all_triggers( $instance, \%params );
759 ## -------------------------------------------------
764 my ( $self, @args ) = @_;
765 local $error_level = ($error_level || 0) + 1;
766 $self->raise_error($self->create_error(@args));
769 sub _inline_throw_error {
770 my ( $self, @args ) = @_;
771 $self->_inline_raise_error($self->_inline_create_error(@args));
775 my ( $self, @args ) = @_;
779 sub _inline_raise_error {
780 my ( $self, $message ) = @_;
782 return 'die ' . $message;
786 my ( $self, @args ) = @_;
790 local $error_level = ($error_level || 0 ) + 1;
792 if ( @args % 2 == 1 ) {
793 unshift @args, "message";
796 my %args = ( metaclass => $self, last_error => $@, @args );
798 $args{depth} += $error_level;
800 my $class = ref $self ? $self->error_class : "Moose::Error::Default";
805 Carp::caller_info($args{depth}),
810 sub _inline_create_error {
811 my ( $self, $msg, $args ) = @_;
812 # XXX ignore $args for now, nothing currently uses it anyway
822 my $class = ref $self ? $self->error_class : "Moose::Error::Default";
826 # don't check inheritance here - the intention is that the class needs
827 # to provide a non-inherited inlining method, because falling back to
828 # the default inlining method is most likely going to be wrong
829 # yes, this is a huge hack, but so is the entire error system, so.
830 return '$meta->create_error(' . $msg . ', ' . $args . ');'
831 unless $class->meta->has_method('_inline_new');
834 # XXX ignore this for now too
835 # Carp::caller_info($args{depth}),
842 # ABSTRACT: The Moose metaclass
850 This class is a subclass of L<Class::MOP::Class> that provides
851 additional Moose-specific functionality.
853 To really understand this class, you will need to start with the
854 L<Class::MOP::Class> documentation. This class can be understood as a
855 set of additional features on top of the basic feature provided by
860 C<Moose::Meta::Class> is a subclass of L<Class::MOP::Class>.
866 =item B<< Moose::Meta::Class->initialize($package_name, %options) >>
868 This overrides the parent's method in order to provide its own
869 defaults for the C<attribute_metaclass>, C<instance_metaclass>, and
870 C<method_metaclass> options.
872 These all default to the appropriate Moose class.
874 =item B<< Moose::Meta::Class->create($package_name, %options) >>
876 This overrides the parent's method in order to accept a C<roles>
877 option. This should be an array reference containing roles
878 that the class does, each optionally followed by a hashref of options
879 (C<-excludes> and C<-alias>).
881 my $metaclass = Moose::Meta::Class->create( 'New::Class', roles => [...] );
883 =item B<< Moose::Meta::Class->create_anon_class >>
885 This overrides the parent's method to accept a C<roles> option, just
888 It also accepts a C<cache> option. If this is true, then the anonymous
889 class will be cached based on its superclasses and roles. If an
890 existing anonymous class in the cache has the same superclasses and
891 roles, it will be reused.
893 my $metaclass = Moose::Meta::Class->create_anon_class(
894 superclasses => ['Foo'],
895 roles => [qw/Some Roles Go Here/],
899 Each entry in both the C<superclasses> and the C<roles> option can be
900 followed by a hash reference with arguments. The C<superclasses>
901 option can be supplied with a L<-version|Class::MOP/Class Loading
902 Options> option that ensures the loaded superclass satisfies the
903 required version. The C<role> option also takes the C<-version> as an
904 argument, but the option hash reference can also contain any other
905 role relevant values like exclusions or parameterized role arguments.
907 =item B<< $metaclass->make_immutable(%options) >>
909 This overrides the parent's method to add a few options. Specifically,
910 it uses the Moose-specific constructor and destructor classes, and
911 enables inlining the destructor.
913 Since Moose always inlines attributes, it sets the C<inline_accessors> option
916 =item B<< $metaclass->new_object(%params) >>
918 This overrides the parent's method in order to add support for
921 =item B<< $metaclass->superclasses(@superclasses) >>
923 This is the accessor allowing you to read or change the parents of
926 Each superclass can be followed by a hash reference containing a
927 L<-version|Class::MOP/Class Loading Options> value. If the version
928 requirement is not satisfied an error will be thrown.
930 =item B<< $metaclass->add_override_method_modifier($name, $sub) >>
932 This adds an C<override> method modifier to the package.
934 =item B<< $metaclass->add_augment_method_modifier($name, $sub) >>
936 This adds an C<augment> method modifier to the package.
938 =item B<< $metaclass->calculate_all_roles >>
940 This will return a unique array of C<Moose::Meta::Role> instances
941 which are attached to this class.
943 =item B<< $metaclass->calculate_all_roles_with_inheritance >>
945 This will return a unique array of C<Moose::Meta::Role> instances
946 which are attached to this class, and each of this class's ancestors.
948 =item B<< $metaclass->add_role($role) >>
950 This takes a L<Moose::Meta::Role> object, and adds it to the class's
951 list of roles. This I<does not> actually apply the role to the class.
953 =item B<< $metaclass->role_applications >>
955 Returns a list of L<Moose::Meta::Role::Application::ToClass>
956 objects, which contain the arguments to role application.
958 =item B<< $metaclass->add_role_application($application) >>
960 This takes a L<Moose::Meta::Role::Application::ToClass> object, and
961 adds it to the class's list of role applications. This I<does not>
962 actually apply any role to the class; it is only for tracking role
965 =item B<< $metaclass->does_role($role) >>
967 This returns a boolean indicating whether or not the class does the specified
968 role. The role provided can be either a role name or a L<Moose::Meta::Role>
969 object. This tests both the class and its parents.
971 =item B<< $metaclass->excludes_role($role_name) >>
973 A class excludes a role if it has already composed a role which
974 excludes the named role. This tests both the class and its parents.
976 =item B<< $metaclass->add_attribute($attr_name, %params|$params) >>
978 This overrides the parent's method in order to allow the parameters to
979 be provided as a hash reference.
981 =item B<< $metaclass->constructor_class($class_name) >>
983 =item B<< $metaclass->destructor_class($class_name) >>
985 These are the names of classes used when making a class immutable. These
986 default to L<Moose::Meta::Method::Constructor> and
987 L<Moose::Meta::Method::Destructor> respectively. These accessors are
988 read-write, so you can use them to change the class name.
990 =item B<< $metaclass->error_class($class_name) >>
992 The name of the class used to throw errors. This defaults to
993 L<Moose::Error::Default>, which generates an error with a stacktrace
994 just like C<Carp::confess>.
996 =item B<< $metaclass->throw_error($message, %extra) >>
998 Throws the error created by C<create_error> using C<raise_error>
1004 See L<Moose/BUGS> for details on reporting bugs.