On Mon, 26 Jun 2006, Bryn Dyment wrote:
> 
> (Apache 1.x)
> 
> I'm having trouble making my ErrorDocument point to a Mason-served page.
> 
> For example, I can hit http://www.example.com/masonpage from the browser 
> but the following:
> 
> ErrorDocument 404    /masonpage
> 
> ... doesn't work.  Any gotchas?

I think it may be that Mason intercepts errors, packages them in 
its own Exception::Class subclasses, and then prints its own 
version of errors.

I played some with the built-in error verbosity but could never 
make it really nice and idiot-proof so that users never see 
technical messages.

I did it something like this in the top-level autohandler:

<%init>
    use My::Exception;  # my own Exception::Class hierarchy package
    use English '-no_match_vars';
</%init>
<%perl>
    eval { $m->call_next() };
    if (my $M_X = Exception::Class->caught('HTML::Mason::Exception')) {
        if ( $M_X->isa('HTML::Mason::Exception::Abort') ) {
            $M_X->rethrow();  # important for redirects
        }
        else {
            warn $M_X; 
            $m->clear_buffer();
            $m->comp('/nice_error.html');
        }
    }
    elsif (my $X = Exception::Class->caught('My::Exception')) {
        warn $X, $X->trace(); 
        $m->clear_buffer();
        $m->comp('/nice_error.html', error => $X->nice_error_message );
    }
    elsif ($EVAL_ERROR) {
        # catch untrapped programming errors
        my $X = My::Exception->new(
            message => 'unhandled autohandler exception',
            error   => $EVAL_ERROR,
        );
        warn $X;
        $m->clear_buffer();
        $m->comp('/nice_error.html');
    }
</%perl>


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to