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

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -