brainsiq / hapi-boom-decorators

Decorates a Hapi server's response toolkit with functions to make it easy to reply with Boom errors
MIT License
29 stars 6 forks source link

Missing 500 #4

Closed jsumners closed 8 years ago

jsumners commented 8 years ago

It's not documented, but Boom has a .internal() method for generating a 500 error. It'd be nice to have it in boom-decorators as well.

brainsiq commented 8 years ago

Cheers! Wasn't aware of that one. Will get it added.

brainsiq commented 8 years ago

Have looked at this a bit more and not sure wrapping Boom.internal() adds anything, as it just passes off to the wrap or create function (depending on whether you pass an error or not).

So I think you could just use the reply.boom() decorated function that is already implemented which does the same thing.

reply.boom(500, new Error(), 'message');
reply.boom(500, 'message', {my_data_attribute: 'something'});

And there is always reply.badImplementation('oops') for generating 500 responses too.

Let me know if I'm missing anything.

jsumners commented 8 years ago

Hmmm, I see now that they have chosen to alias "internal" as "badImplementation" for the public API. I disagree with that choice, but that's irrelevant to this issue. Thank you for clarifying.

brainsiq commented 8 years ago

Not clear what their intention is with internal vs badImplementation really. The later does set an additional boolean flag on the Boom object so they're perhaps not completely interchangeable.