Closed kanongil closed 3 years ago
Why does the Boom constructor not return an instance of itself? imo this is just as bad a pattern as the bug you are fixing. The constructor is essentially a factory method.
Yeah, that's exactly right— as I think about it the constructor exists for the convenience of being able to use instanceof Boom
on boom errors or boomified user errors which originate outside boom. The docs (originally written in the commit closing #173) talk a little bit more about intended usage and why it works that way.
This should fix the false positives reported in #285. Now any
instanceof
check called on aBoom
subclass will effectively returnfalse
, since the actual returned object from the constructor is never aBoom
object.I used https://stackoverflow.com/a/57898482/248062 as input.