javascript - Catch Error Type in Bluebird Not Working -
i have custom error class:
class networkerror extends error { constructor() { super('network error'); this.name = 'networkerror'; } }
and want handle specifically:
import {networkerror} '../../common/errors'; somefunc().catch(networkerror, err => { // missed }).catch(err => { // hit });
but it's skipping custom catch , hitting general catch. if change so, works:
somefunc().catch({name: 'networkerror'}, err => { // hit }).catch(err => { // missed });
obviously first way preferred. missing here?
as @loganfsmyth suggested in question comments, it's babel limitation. answer trick:
why doesn't instanceof work on instances of error subclasses under babel-node?
wiki
Comments
Post a Comment