If the server detects an error condition during processing of a request, then the response contains a status code indicating the cause of the error. Common status codes are 404 if a page is not found and 401 if the client is not authorized.
Then, the browser displays an error page describing the error. However, it is also possible to send an HTML page, together with the status code. To enable this feature, you need to provide an HTTPServerErrorPageHandler
delegate. This handler can then, for example, render a template.
You can create a small application to demonstrates this, as shown in the following:
Create a new project with
dub
:$ dub init errorpage --type=vibe.d
Create a
index.dt
template in theviews
folder. It contains a link to a non-existent page:doctype html head title Error page demonstration body p Click on the <a href="/notfound">link</a> to generate a 404 error.
Create a
error.dt
template in theviews
folder. This will display information...