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
message.

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

        }

        my $c = $class->prepare(@arguments);
        $c->dispatch;
        $status = $c->finalize;
    };

    if ( my $error = $@ ) {
        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
uploads.

    my $croaked;

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

        $c->NEXT::prepare_body(@_);

    }

    if ( $croaked ) {
        if ( my $id = $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 = $c->cache->get( 'upload_progress_' . $id ) || {};

            $progress->{aborted} = 1;


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

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







-- 
Bill Moseley
mose...@hank.org
_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to