[Catalyst-commits] r14480 - trunk/examples/CatalystAdvent/root/2013

jnapiorkowski at dev.catalyst.perl.org jnapiorkowski at dev.catalyst.perl.org
Sat Dec 7 14:21:51 GMT 2013


Author: jnapiorkowski
Date: 2013-12-07 14:21:51 +0000 (Sat, 07 Dec 2013)
New Revision: 14480

Modified:
   trunk/examples/CatalystAdvent/root/2013/14.pod
Log:
fixed missing error handler

Modified: trunk/examples/CatalystAdvent/root/2013/14.pod
===================================================================
--- trunk/examples/CatalystAdvent/root/2013/14.pod	2013-12-06 20:30:39 UTC (rev 14479)
+++ trunk/examples/CatalystAdvent/root/2013/14.pod	2013-12-07 14:21:51 UTC (rev 14480)
@@ -93,19 +93,21 @@
     }
 
     sub read_chunk {
-      my ($self, $fh, $offset) = @_;
-      my $buffer = '';
-      aio_read $fh, $offset, 65536, $buffer, 0, sub {
-        my $status = shift;
-        die "read error[$status]: $!" unless $status >= 0;
-        if($status) {
-          $self->write($buffer);
-          $self->read_chunk($fh, ($offset + 65536));
-        } else {
-          $self->close;
-          aio_close $fh, sub { };
-        }
-      }
+       my ($self, $fh, $offset) = @_;
+       my $buffer = '';
+       aio_read $fh, $offset, 65536, $buffer, 0, sub {
+         my $status = shift;
+         die "read error[$status]: $!" unless $status >= 0;
+         if($status) {
+           eval {
+             $self->write($buffer); 1;
+           } || warn "Cannot write, probably a closed pipe: $@";
+           $self->read_chunk($fh, ($offset + 65536));
+         } else {
+           $self->close;
+           aio_close $fh, sub { };
+         }
+       }
     }
 
 One nice thing about doing this is how easy it is to write a test case and to




More information about the Catalyst-commits mailing list