hapijs / boom

HTTP-friendly error objects
Other
2.94k stars 192 forks source link

Error in Boom instance #257

Closed jquiceno closed 5 years ago

jquiceno commented 5 years ago

Support plan

Context

How can we help?

The problem is when I try to instantiate a new object in Boom

const Boom = require('@hapi/boom')
const e = new Boom('Test error')

This generates an error like this: TypeError: Boom is not a constructor

My implementation is something similar to this:

try {
      message = await message.data()

      if (!message) {
        throw Boom.badRequest('Message not found or invalid')
      }

      return Promise.resolve(message)
    } catch (e) {
      return Promise.reject(new Boom(e))
    }

This problem only appears in version 8.xx, when returning to version 7.xx this does not happen, I thought it could be an update but I can see that in the documentation of version 8.xx it still exists, this makes me think What is a problem.

Try the problem directly in npm runkit, and the problem continues. https://npm.runkit.com/@hapi/boom

hueniverse commented 5 years ago

You should read the release notes when upgrading to a new major version. You need to do ‘new Boom.Boom();’

AdriVanHoudt commented 5 years ago

@hueniverse did you not release this change in 8.0.1 as a patch? Seems weird to change an interface in a patch version no?

hueniverse commented 5 years ago

8.0.0 was unpublished so no, not a patch.

AdriVanHoudt commented 5 years ago

But you published 8.0.1 a day after 8.0.0 no? It is safe to say that multiple people have upgraded (including me) during that time and then saw a patch version after (so as an actual patch version not major).

hueniverse commented 5 years ago

8.0.0 was a mistake. It wasn't ready.