FAQ
Hi,

Is it possible to change that multilanguage message that Catalyst displays
when the application gives an error?

It is that message with "Please come back later" in a few languages.

I would like to be able to display a page made by me when such an error
should appear.

Thank you.

Octavian

Search Discussions

  • Tobias Kremer at Jun 25, 2007 at 12:57 pm

    Zitat von Octavian Rasnita <orasnita@gmail.com>:
    Is it possible to change that multilanguage message that Catalyst displays
    when the application gives an error?

    It is that message with "Please come back later" in a few languages.

    I would like to be able to display a page made by me when such an error
    should appear.
    http://search.cpan.org/dist/Catalyst-Manual/lib/Catalyst/Manual/Cookbook.pod#Delivering_a_Custom_Error_Page

    --Tobias
  • Evaldas Imbrasas at Jun 25, 2007 at 4:40 pm
    Actually, the example below doesn't work if there are any TT rendering errors.

    Is there a catch-all solution, or does it have to be done on the Apache level?


    --
    -----------------------------------------------------
    Evaldas Imbrasas
    http://www.imbrasas.com
  • John Napiorkowski at Jun 25, 2007 at 5:13 pm

    --- Evaldas Imbrasas wrote:

    Actually, the example below doesn't work if there
    are any TT rendering errors.

    Is there a catch-all solution, or does it have to be
    done on the Apache level?
    I'm not sure what you mean. If you are running in
    mod_perl and set an error status (4xx or 5xx) Apache
    will (in it's relatively default config) display a
    standard template in various languages, depending on
    the language setting for the client. You can edit
    these if you like.

    If you want catalyst to handle all this, you need to
    remove that apache stuff and catch all the error codes
    and build templates as you like. Catalyst doesn't
    have this templates out of the box, you need to catch
    errors codes and direct them to templates you made,
    but it would be a really nice project for someone to
    do. Right now the non debug /debug message is just
    inlined html in the Catalyst::Engine module. It would
    be cool to break this out and have some default
    templates in TT, Mason, etc.

    --john

    http://search.cpan.org/dist/Catalyst-Manual/lib/Catalyst/Manual/Cookbook.pod#Delivering_a_Custom_Error_Page

    --
    -----------------------------------------------------
    Evaldas Imbrasas
    http://www.imbrasas.com

    _______________________________________________
    List: Catalyst@lists.rawmode.org
    Listinfo:
    http://lists.rawmode.org/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.rawmode.org/
    Dev site: http://dev.catalyst.perl.org/



    ____________________________________________________________________________________
    Yahoo! oneSearch: Finally, mobile search
    that gives answers, not web links.
    http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
  • Brian Kirkbride at Jun 25, 2007 at 5:32 pm

    John Napiorkowski wrote:
    --- Evaldas Imbrasas wrote:
    Actually, the example below doesn't work if there
    are any TT rendering errors.

    Is there a catch-all solution, or does it have to be
    done on the Apache level?
    I'm not sure what you mean. If you are running in
    mod_perl and set an error status (4xx or 5xx) Apache
    will (in it's relatively default config) display a
    standard template in various languages, depending on
    the language setting for the client. You can edit
    these if you like.

    If you want catalyst to handle all this, you need to
    remove that apache stuff and catch all the error codes
    and build templates as you like. Catalyst doesn't
    have this templates out of the box, you need to catch
    errors codes and direct them to templates you made,
    but it would be a really nice project for someone to
    do. Right now the non debug /debug message is just
    inlined html in the Catalyst::Engine module. It would
    be cool to break this out and have some default
    templates in TT, Mason, etc.

    --john
    I think what Evaldas means is that an error (template not found, etc)
    in the View rendering stage will not be caught by the method in the
    Cookbook.

    I am away from my code at the moment, but IIRC the trick is to check
    $c->error AFTER you forward to MyApp::V::TT (or after the RenderView
    action) and then setup your error.tt template and forward to the view
    again.

    If that doesn't make sense I can provide a code example later.

    Best,
    Brian
  • Evaldas Imbrasas at Jun 25, 2007 at 6:26 pm
    Yes, that's what I meant, thanks Brian. Please provide a code example
    using RenderView action. I think it would also make sense to
    incorporate that example into the Catalyst cookbook instead of
    existing one since that one's incomplete.
    I think what Evaldas means is that an error (template not found, etc)
    in the View rendering stage will not be caught by the method in the
    Cookbook.

    I am away from my code at the moment, but IIRC the trick is to check
    $c->error AFTER you forward to MyApp::V::TT (or after the RenderView
    action) and then setup your error.tt template and forward to the view
    again.

    If that doesn't make sense I can provide a code example later.
    --
    -----------------------------------------------------
    Evaldas Imbrasas
    http://www.imbrasas.com
  • Jason Kohles at Jun 26, 2007 at 5:00 pm

    On Jun 25, 2007, at 1:27 PM, Evaldas Imbrasas wrote:

    Yes, that's what I meant, thanks Brian. Please provide a code example
    using RenderView action. I think it would also make sense to
    incorporate that example into the Catalyst cookbook instead of
    existing one since that one's incomplete.
    Something like this...

    sub render : ActionClass('RenderView') { }

    sub end : Private {
    my ( $self, $c ) = @_;

    $c->forward( 'render' );

    if ( my @errors = @{ $c->errors } ) {
    $c->response->content_type( 'text/html' );
    $c->response->status( 500 );
    $c->response->body( qq{
    <html>
    <head>
    <title>Error!</title>
    </head>
    <body>
    <h1>Oh no! An Error!</h1>
    } . ( map { "<p>$_</p>" } @errors ) . qq{
    </body>
    </html>
    } );
    }
    }
    I think what Evaldas means is that an error (template not found, etc)
    in the View rendering stage will not be caught by the method in the
    Cookbook.

    I am away from my code at the moment, but IIRC the trick is to check
    $c->error AFTER you forward to MyApp::V::TT (or after the RenderView
    action) and then setup your error.tt template and forward to the view
    again.

    If that doesn't make sense I can provide a code example later.
    --
    -----------------------------------------------------
    Evaldas Imbrasas
    http://www.imbrasas.com

    _______________________________________________
    List: Catalyst@lists.rawmode.org
    Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/
    catalyst@lists.rawmode.org/
    Dev site: http://dev.catalyst.perl.org/
    --
    Jason Kohles
    email@jasonkohles.com
    http://www.jasonkohles.com/
    "A witty saying proves nothing." -- Voltaire
  • Brian Kirkbride at Jun 26, 2007 at 5:45 pm

    Jason Kohles wrote:
    On Jun 25, 2007, at 1:27 PM, Evaldas Imbrasas wrote:

    Yes, that's what I meant, thanks Brian. Please provide a code example
    using RenderView action. I think it would also make sense to
    incorporate that example into the Catalyst cookbook instead of
    existing one since that one's incomplete.
    Something like this...

    sub render : ActionClass('RenderView') { }

    sub end : Private {
    my ( $self, $c ) = @_;

    $c->forward( 'render' );

    if ( my @errors = @{ $c->errors } ) {
    $c->response->content_type( 'text/html' );
    $c->response->status( 500 );
    $c->response->body( qq{
    <html>
    <head>
    <title>Error!</title>
    </head>
    <body>
    <h1>Oh no! An Error!</h1>
    } . ( map { "<p>$_</p>" } @errors ) . qq{
    </body>
    </html>
    } );
    }
    }
    Or even this:

    sub render : ActionClass('RenderView') {}
    sub end : Private {
    my ($self,$c) = @_;
    $c->forward('render');
    if (my @errors = @{$c->errors}) {
    $c->errors(0);
    $c->stash->{template} = 'error.tt';
    $c->stash->{errors} = \@errors;
    $c->forward($c->view('TT'));
    }
    }

    To allow for a templated error page.

    Best,
    Brian
  • Brian Kirkbride at Jun 26, 2007 at 7:33 pm

    Brian Kirkbride wrote:
    Jason Kohles wrote:
    On Jun 25, 2007, at 1:27 PM, Evaldas Imbrasas wrote:

    Yes, that's what I meant, thanks Brian. Please provide a code example
    using RenderView action. I think it would also make sense to
    incorporate that example into the Catalyst cookbook instead of
    existing one since that one's incomplete.
    Something like this...

    sub render : ActionClass('RenderView') { }

    sub end : Private {
    my ( $self, $c ) = @_;

    $c->forward( 'render' );

    if ( my @errors = @{ $c->errors } ) {
    $c->response->content_type( 'text/html' );
    $c->response->status( 500 );
    $c->response->body( qq{
    <html>
    <head>
    <title>Error!</title>
    </head>
    <body>
    <h1>Oh no! An Error!</h1>
    } . ( map { "<p>$_</p>" } @errors ) . qq{
    </body>
    </html>
    } );
    }
    }
    Or even this:

    sub render : ActionClass('RenderView') {}
    sub end : Private {
    my ($self,$c) = @_;
    $c->forward('render');
    if (my @errors = @{$c->errors}) {
    $c->errors(0);
    $c->stash->{template} = 'error.tt';
    $c->stash->{errors} = \@errors;
    $c->forward($c->view('TT'));
    }
    }

    To allow for a templated error page.

    Best,
    Brian
    Actually, you'd probably want that to be:

    $c->forward('render') unless @{$c->errors};

    to avoid rendering a template when an error occurred during the action.
  • Jason Kohles at Jun 27, 2007 at 2:15 pm

    On Jun 26, 2007, at 12:45 PM, Brian Kirkbride wrote:

    Jason Kohles wrote:
    On Jun 25, 2007, at 1:27 PM, Evaldas Imbrasas wrote:
    Yes, that's what I meant, thanks Brian. Please provide a code
    example
    using RenderView action. I think it would also make sense to
    incorporate that example into the Catalyst cookbook instead of
    existing one since that one's incomplete.
    Something like this...
    sub render : ActionClass('RenderView') { }
    sub end : Private {
    Or even this:

    sub render : ActionClass('RenderView') {}
    sub end : Private {
    my ($self,$c) = @_;
    $c->forward('render');
    if (my @errors = @{$c->errors}) {
    $c->errors(0);
    $c->stash->{template} = 'error.tt';
    $c->stash->{errors} = \@errors;
    $c->forward($c->view('TT'));
    }
    }

    To allow for a templated error page.
    The original question was how to deal with the view failing. If your
    view is
    broken, you probably don't want to try and use it to render the error...

    --
    Jason Kohles
    email@jasonkohles.com
    http://www.jasonkohles.com/
    "A witty saying proves nothing." -- Voltaire
  • Brian Kirkbride at Jun 27, 2007 at 4:51 pm

    Jason Kohles wrote:
    On Jun 26, 2007, at 12:45 PM, Brian Kirkbride wrote:

    Jason Kohles wrote:
    On Jun 25, 2007, at 1:27 PM, Evaldas Imbrasas wrote:
    Yes, that's what I meant, thanks Brian. Please provide a code example
    using RenderView action. I think it would also make sense to
    incorporate that example into the Catalyst cookbook instead of
    existing one since that one's incomplete.
    Something like this...
    sub render : ActionClass('RenderView') { }
    sub end : Private {
    Or even this:

    sub render : ActionClass('RenderView') {}
    sub end : Private {
    my ($self,$c) = @_;
    $c->forward('render');
    if (my @errors = @{$c->errors}) {
    $c->errors(0);
    $c->stash->{template} = 'error.tt';
    $c->stash->{errors} = \@errors;
    $c->forward($c->view('TT'));
    }
    }

    To allow for a templated error page.
    The original question was how to deal with the view failing. If your
    view is
    broken, you probably don't want to try and use it to render the error...
    If the error in the View is that the template was not found, or that
    it had a syntax error, you can render a templatized error page with no
    problem.

    Point taken though, the proper solution is probably to try the View's
    error page, catch any errors and fallback to your original solution.

    Best,
    Brian

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedJun 25, '07 at 10:40a
activeJun 27, '07 at 4:51p
posts11
users6
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase