Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to override 404 and 500 pages using japid ? #62

Open
PerfectCarl opened this issue Oct 21, 2013 · 1 comment
Open

How to override 404 and 500 pages using japid ? #62

PerfectCarl opened this issue Oct 21, 2013 · 1 comment

Comments

@PerfectCarl
Copy link

Play lets us override the default page hander for 404 and 500 errors.

views/errors/404.html

<!DOCTYPE html>

<html>
    <head>
        <title>Not found</title>
        <meta http-equiv="Content-Type" content="text/html; charset=${_response_encoding}"/>    
    </head>
    <body>
        #{if play.mode.name() == 'DEV'}
            #{404 result /}
        #{/if}
        #{else}
            <h1>Not found</h1>
            <p>
                ${result.message}
            </p>
        #{/else}
    </body>
</html>

views/errors/500.html

<!DOCTYPE html>

<html>
    <head>
        <title>Application error</title>
        <meta http-equiv="Content-Type" content="text/html; charset=${_response_encoding}"/>    
    </head>
    <body>
        #{if play.mode.name() == 'DEV'}
            #{500 exception /}
        #{/if}
        #{else}
            <h1>Oops, an error occured</h1>
            #{if exception instanceof play.exceptions.PlayException}
                <p>
                    This exception has been logged with id <strong>${exception.id}</strong>.
                </p>
            #{/if}
        #{/else}
    </body>
</html>

What is the japid way to do it ?

@branaway
Copy link
Owner

One way is to change the default 404 page to refer to a japid version, eg: (in app/views/errors/404.html)

<html>
    <head>
        <title>Not found</title>
    </head>
    <body>
        #{if play.mode.name() == 'DEV'}
            #{404 result /}
        #{/if}
        #{else}
        ${cn.bran.play.JapidPlayRenderer.renderWith("japidviews.error404").raw()}
        #{/else}
    </body>
</html>

Then do whatever you want with an Japid based "error404.html" in you japidviews folder.

The above example let your Japid 404 page to handle 404 in prod mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants