Promises and generic .catch() statements

后端 未结 3 2117
情话喂你
情话喂你 2021-01-04 17:47

I\'m writing an API for my system, that\'s sending an XHR to the server and returns a promise that should be handled by the caller - so far so good.

For each API cal

3条回答
  •  执笔经年
    2021-01-04 18:10

    I think all you want to do is rethrow the exception after you've logged it so other handlers will deal with it properly:

    return deferred.promise.catch(function (error) {
      console.error(error);
      throw e; // rethrow the promise
    });
    

提交回复
热议问题