蓝鸟过滤捕捉巴贝尔和扩展错误类

我运行一个nodejs(服务器)项目(v6.11.2),并通过扩展Error类定义了自定义错误。 我使用babel编译,我使用的babelconfiguration是:

{ "presets": [ ["env", { "targets": { "node": "current" } }] ] } 

AppError类:

 export default class AppError extends Error { constructor (message, status) { super(message); this.name = this.constructor.name; Error.captureStackTrace(this, this.constructor); this.status = status || 500; } } 

我想检查如果取消方法抛出一个AppError。 当我尝试使用蓝鸟过滤的catch,我得到以下错误:

类构造函数AppError不能被调用没有“新”

 cancel() .catch(AppError, (e) => { // This is not working }); 

但是下面的代码将会正常工作:

 cancel() .catch((e) => { if (e instanceof AppError) { // This is working } throw e; }); 

有人可以解释为什么蓝鸟方法不工作?

我已经看到这个post: 为什么没有instanceof工作在babel-node下的错误子类的实例? 但我无法弄清楚。