goto \&confess
}
+sub throw_exception {
+ shift;
+
+ my %args;
+ if (@_ == 1) {
+ $args{message} = shift;
+ }
+ else {
+ %args = @_;
+ }
+
+ my $roles = delete($args{roles});
+
+ my $metaclass = Moose::Meta::Class->create_anon_class(
+ superclasses => ['Throwable::Error'],
+ ($roles ? (roles => $roles) : ()),
+ );
+
+ $metaclass->name->throw(\%args);
+}
+
sub extends {
my $meta = shift;
- Moose->throw_error("Must derive at least one class") unless @_;
+ Moose->throw_exception("Must derive at least one class") unless @_;
# this checks the metaclass to make sure
# it is correct, sometimes it can get out
See L<Metaclass and Trait Name Resolution> for details on how a trait name is
resolved to a role name.
-Also see L<Moose::Cookbook::Meta::Recipe3> for a metaclass trait
-example.
+Also see L<Moose::Cookbook::Meta::Labeled_AttributeTrait> for a metaclass
+trait example.
=item I<builder> => Str
for a class matching B<Moose::Meta::$type::Custom::$metaclass_name>.
If all this is confusing, take a look at
-L<Moose::Cookbook::Meta::Recipe3>, which demonstrates how to create an
-attribute trait.
+L<Moose::Cookbook::Meta::Labeled_AttributeTrait>, which demonstrates how to
+create an attribute trait.
=head1 UNIMPORTING FUNCTIONS
To learn more about extending Moose, we recommend checking out the
"Extending" recipes in the L<Moose::Cookbook>, starting with
-L<Moose::Cookbook::Extending::Recipe1>, which provides an overview of
+L<Moose::Cookbook::Extending::ExtensionOverview>, which provides an overview of
all the different ways you might extend Moose. L<Moose::Exporter> and
L<Moose::Util::MetaRole> are the modules which provide the majority of the
extension functionality, so reading their documentation should also be helpful.