If you pass no roles, just instantiate the superclass.
Shawn M Moore [Thu, 14 Jun 2012 20:01:26 +0000 (15:01 -0500)]
    I feel like I want MooseX::ClassCompositor here.

lib/Moose/Util.pm

index 28ec30f..5e0e99d 100644 (file)
@@ -480,13 +480,20 @@ sub throw {
         %args = @_;
     }
 
-    my $superclasses = delete($args{superclasses}) || ['Throwable::Error'];
+    my $superclass = delete($args{superclass}) || 'Throwable::Error';
     my $roles = delete($args{roles});
 
-    my $metaclass = Moose::Meta::Class->create_anon_class(
-        superclasses => $superclasses,
-        ($roles ? (roles => $roles) : ()),
-    );
+    my $metaclass;
+
+    if ($roles) {
+        $metaclass = Moose::Meta::Class->create_anon_class(
+            superclasses => [$superclass],
+            roles        => $roles,
+        );
+    }
+    else {
+        $metaclass = Moose::Meta::Class->initialize($superclass);
+    }
 
     $metaclass->name->throw(\%args);
 }