[Catalyst] Suppressing exceptions in Engine / UploadProgress

Bill Moseley moseley at hank.org
Mon Nov 9 03:58:12 GMT 2009

I'm running under mod_perl, and when a user aborts an upload I get an error
in the log.

[error] Caught exception in engine "Apache2::RequestIO::read: (70014)
End of file found at /usr/local/share/perl/5.10.0/Catalyst/Engine/Apache.pm
line 187"

I don't see that it's possible, but is there any way to ignore some
exceptions (similar to how execute() can ignore a detach)?   Not sure
there's a good case for it, other than to simply ignore the above.  (I can
modify my log monitoring to ignore those, for example).  But, there doesnt's
seen to be any way to get out of that block without generating an error

    eval {
        if ($class->debug) {
            my $secs =3D time - $START || 1;
            my $av =3D sprintf '%.3f', $COUNT / $secs;
            my $time =3D localtime time;
            $class->log->info("*** Request $COUNT ($av/s) [$$] [$time] ***"=


        my $c =3D $class->prepare(@arguments);
        $status =3D $c->finalize;

    if ( my $error =3D $@ ) {
        chomp $error;
        $class->log->error(qq/Caught exception in engine "$error"/);


Maybe I could override prepare() and return a different $c object with dummy
dispatch and finalize methods, but I suspect another prepare() and that
approach would break.

BTW -- I was looking at this along with the UploadProgress plugin.  It does
this to catch aborted uploads.
The plugin is a bit old, but doesn't seem like overriding croak is a good
way to catch exceptions.  Is there any reason not to wrap prepare_body in an
eval?   Yep, I just tried and under mod_perl2 this doesn't catch aborted

    my $croaked;

        no warnings 'redefine';
        local *Carp::croak =3D sub {
            $croaked =3D shift;



    if ( $croaked ) {
        if ( my $id =3D $c->req->query_parameters->{progress_id} ) {
            $c->log->info( "UploadProgress: User aborted upload $id" );

            # Update progress to flag this so javascript will stop polling
            my $progress =3D $c->cache->get( 'upload_progress_' . $id ) || =

            $progress->{aborted} =3D 1;

            $c->cache->set( 'upload_progress_' . $id, $progress );

        # rethrow the error
        Catalyst::Exception->throw( $croaked );

-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20091108/f2cbf=

More information about the Catalyst mailing list