Convert extends() to throw_exception
[gitmo/Moose.git] / lib / Moose.pm
index 4cfa28d..b454797 100644 (file)
@@ -46,10 +46,31 @@ sub throw_error {
     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
@@ -637,8 +658,8 @@ cover here.
 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
 
@@ -842,8 +863,8 @@ The lookup method for metaclasses is the same, except that it looks
 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
 
@@ -870,7 +891,7 @@ to work. Here is an example:
 
 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.