packages: irssi-scripts/gtrans.pl - catch die from wgl_process ($service->t...

glen glen at pld-linux.org
Wed Feb 24 15:59:48 CET 2010


Author: glen                         Date: Wed Feb 24 14:59:48 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- catch die from wgl_process ($service->translate throws one on connect timeouts)

---- Files affected:
packages/irssi-scripts:
   gtrans.pl (1.3 -> 1.4) 

---- Diffs:

================================================================
Index: packages/irssi-scripts/gtrans.pl
diff -u packages/irssi-scripts/gtrans.pl:1.3 packages/irssi-scripts/gtrans.pl:1.4
--- packages/irssi-scripts/gtrans.pl:1.3	Tue Dec 29 08:36:46 2009
+++ packages/irssi-scripts/gtrans.pl	Wed Feb 24 15:59:43 2010
@@ -222,8 +222,15 @@
   my %args = @_;
   dbg(5, "wgl_process(): input %args: " . Dumper(\%args));
 
-  my $result = $args{func}(%args);
-  dbg(4, "wgl_process() wgl_func() output: " . Dumper(\$result));
+  my $result;
+  eval {
+    $result = $args{func}(%args);
+    dbg(4, "wgl_process() wgl_func() output: " . Dumper(\$result));
+  };
+  if ($@) {
+    err(sprintf "wgl_process() wgl_func() %s", $@);
+    return;
+  }
 
   my $ok = 1;
   if ($result->error) {
@@ -311,6 +318,9 @@
 
   # Run language detection.
   my $result = wgl_process(%args);
+  if (!$result) {
+    return;
+  }
 
   dbg(4, "$subname() wgl_process() detect returned: " .
          Dumper(\$result));
@@ -341,6 +351,7 @@
   my $reliable = $result->is_reliable;
 
   # Prepare arguments for translation.
+  # TODO: need wrap eval around service translate
   %args = (
     "func" => sub { $service->translate(@_) },
     "text" => $msg,
@@ -350,6 +361,9 @@
 
   # Run translation.
   $result = wgl_process(%args);
+  if (!$result) {
+    return;
+  }
 
   dbg(4, "$subname() wgl_process() translate returned: " .
          Dumper(\$result));
@@ -452,6 +466,9 @@
 
   # Run translation.
   my $result = wgl_process(%args);
+  if (!$result) {
+    return;
+  }
 
   dbg(4, "$subname() wgl_process() output: " .
          Dumper(\$result));
@@ -644,6 +661,9 @@
 
     # Run translation.
     my $result = wgl_process(%args);
+    if (!$result) {
+      return;
+    }
 
     dbg(4, "$subname() wgl_process() output: " . Dumper(\$result));
 
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/irssi-scripts/gtrans.pl?r1=1.3&r2=1.4&f=u



More information about the pld-cvs-commit mailing list