Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
hapi plugin to reformat boom errors to json-api
exports.register = function (plugin, options, done) {
plugin.ext('onPreResponse', function (request, reply) {
var response = request.response;
if (response.isBoom) {
var error = {
title: response.output.payload.error,
status: response.output.statusCode,
detail: response.output.payload.message
response.output.payload = { errors: [error] };
return reply.continue();
return done();
exports.register.attributes = {
name: 'hapi-boom-json-api',
version: '1.0.0'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.