Package Exports
- hapi-error-page
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hapi-error-page) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
hapi-error-page 
Friendly error pages for humans
This hapi plugin makes it easy to return beautiful HTML error pages to your users.
Why?
- Errors in hapi are displayed as JSON by default.
- JSON is good for machines but bad for people.
- Works with AJAX / APIs (respects the
Accept
header).
Install
npm install hapi-error-page
Usage
Register the plugin on your server to enable friendly error pages.
const hapi = require('@hapi/hapi');
const vision = require('@hapi/vision');
const errorPage = require('hapi-error-page');
const server = hapi.server();
const init = async () => {
await server.register([vision, errorPage]);
server.views({
engines : { html : handlebars },
relativeTo : __dirname,
path : '.'
});
server.route({
method : 'GET',
path : '/',
handler() {
throw new Error('uh oh');
}
});
await server.start();
console.log('Server ready:', server.info.uri);
};
init();
Visiting the above route will return an HTML error page rendered by Handlebars from a view file named error.html
. You can, of course, use other templating engines instead (see the vision documentation for details).
Please use boom to construct errors instead of new Error()
, so that we can deliver more useful messages. This project will function correctly either way, but boom
is preferred.
Contributing
See our contributing guidelines for more details.
- Fork it.
- Make a feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request.
License
Go make something, dang it.