Skip to content

@belgattitude/http-exception@1.0.2

Compare
Choose a tag to compare
@belgattitude belgattitude released this 21 Sep 00:38
· 418 commits to main since this release
0ad4479

Patch Changes

  • #51 421b36d Thanks @belgattitude! - Fix Error.cause on node < 16.9 and browsers that don't support for it.

    • Browser currently 89% support: caniuse#error.cause - (89% supports it as of sept 2022)
    • Node from 16.9.0 as per mdn.

    The strategy used can be summarized as:

    If the browser or the node runtime does not support Error.cause parameter in the
    constructor, it will simply be discarded.
    ie:

    const err = new HttpNotFound({cause: new Error()});
    console.log(err.cause) -> undefined if no support
    console.log(err.cause) -> Error cause if supported
    

    To enable older browser or previous node versions, there's 2 polyfills that should
    do the job