makeomatic/redux-connect

Handle thrown errors in promise callbacks

开放

#108 创建于 2017年2月23日

 (4 条评论) (3 个反应) (0 位负责人)JavaScript (73 个派生)batch import
enhancementhelp wanted

仓库指标

星标
 (550 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

This line of code does not catch errors so instead they get lost in the event loop and the component never gets rendered correctly. Additionally, it's hard to catch and display the error in an isomorphic app.

Something like this would reproduce it:

@asyncConnect([{
  deferred: true,
  promise: () => {
    throw new Error('whoops, this was not supposed to happen');
  },
}])
class SomeComponent extends React.Component {
  ...
}

It should be fixable like this:

let promiseOrResult;
try {
  promiseOrResult = item.promise(rest);
} catch (error) {
  promiseOrResult = Promise.reject(error);
}

贡献者指南