Skip to content

Instantly share code, notes, and snippets.

View mmadden's full-sized avatar

Matt Madden mmadden

  • Ontario, Canada
View GitHub Profile
@mmadden
mmadden / hapi-boom-json-api.js
Last active August 29, 2015 14:26
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