Error page - limburgie/c3s GitHub Wiki

C3S can show an error page if any type of error occurs when constructing the requested page. In this page we'll explain how to configure this page and how the underlying exception can be retrieved.

Configuring an error page

The error page is configured inside c3s.json:

{
    "name": "C3S Quickstart site",

    "errorPage": {
        "name": "Error",
        "contents": "pages/error.ftl"
    }

Notice that the error page is an actual page with its own contents. Of course, when you're using page templates, you can also reference a template instead:

{
    "name": "C3S Quickstart site",

    "errorPage": {
        "name": "Error",
        "template": "main",
        "inserts": {
            "body": "pages/error.ftl"
        }
    }

Retrieving and printing the error

For debugging purposes, the exception that was the cause of the error is automatically passed through to the page as a request parameter. So inside the error.ftl you can print out the exception trace when desired:

<p>An error occurred while requesting this page. For details, inspect the exception trace below.</p>

<pre><code>${request.params[0]}</code></pre>

This can be useful for debugging purposes, but is of course not really recommended for production (unless you can hide it behind some switch)!

⚠️ **GitHub.com Fallback** ⚠️