basically operating chain code
[scpubgit/Clifton.git] / lib / App / Clifton / Component.pm
index 7f80acd..6f857ba 100644 (file)
@@ -6,6 +6,7 @@ sub _debug_self {
   "${self}: ".join ', ', map "$_ => ".$args->{$_}, keys %$args;
 }
 
+use Try::Tiny;
 use Log::Contextual qw(:log);
 use Moo;
 
@@ -54,9 +55,7 @@ sub _eval_cb {
   my ($self, $code) = @_;
   my $str = "$self";
   sub {
-    local $@;
-    eval { $code->(@_); 1 }
-      or log_error { "Exception from ${self}: $@" };
+    try { $code->(@_) } catch { log_error { "Exception from ${self}: $_" } }
   };
 }