Change caller to show blocks belonging to our caller
Mark Fowler [Wed, 25 Jul 2012 15:13:56 +0000 (11:13 -0400)]
lib/Try/Tiny.pm

index 7e0ee47..bf2a91e 100644 (file)
@@ -50,9 +50,10 @@ sub try (&;@) {
   # $catch->();
 
   # name the blocks if we have Sub::Name installed
-  subname("try {...}" => $try);
-  subname("catch {...} " => $catch) if $catch;
-  subname("finally {...} " => $_) foreach @finally;
+  my $caller = caller;
+  subname("${caller}::try {...}" => $try);
+  subname("${caller}::catch {...} " => $catch) if $catch;
+  subname("${caller}::finally {...} " => $_) foreach @finally;
 
   # save the value of $@ so we can set $@ back to it in the beginning of the eval
   # and restore $@ after the eval finishes