makeomatic/redux-connect

Handle thrown errors in promise callbacks

Open

#108 ouverte le 23 févr. 2017

Voir sur GitHub
 (4 commentaires) (3 réactions) (0 assignés)JavaScript (73 forks)batch import
enhancementhelp wanted

Métriques du dépôt

Stars
 (550 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

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);
}

Guide contributeur