Incorporate the throw_error bits from Moose turnk
[gitmo/MooseX-Singleton.git] / lib / MooseX / Singleton / Meta / Method / Constructor.pm
index 520483a..6e83444 100644 (file)
@@ -64,7 +64,10 @@ sub initialize_body {
         } @type_constraints;
 
         $code = eval $source;
-        confess "Could not eval the constructor :\n\n$source\n\nbecause :\n\n$@" if $@;
+        $self->throw_error(
+            "Could not eval the constructor :\n\n$source\n\nbecause :\n\n$@",
+            error => $@, data => $source )
+            if $@;
     }
     $self->{'body'} = $code;
 }