Skip to content

Commit

Permalink
Merge pull request #78 from dora-js/enhance-error-catch
Browse files Browse the repository at this point in the history
enhancement error catch, Close #76
  • Loading branch information
soda-x committed Aug 1, 2016
2 parents bf13def + c245777 commit 10573ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,14 @@ export function applyPlugins(plugins, name, context, pluginArgs, _callback = fun
} else {
const funcResult = func.call(contextModify, memo);
if (funcResult && funcResult.then) {
funcResult.then(result => {
funcResult
.then(result => {
callback(null, result);
}).catch(callback);
})
.catch(callback)
.catch(err => {
throw new Error(err);
});
} else {
callback(null, funcResult);
}
Expand Down
4 changes: 3 additions & 1 deletion src/reduceAsync.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export default function reduceAsync(arr, memo, iterator, callback) {
let _memo = memo;
let index = 0;
Expand All @@ -14,6 +13,9 @@ export default function reduceAsync(arr, memo, iterator, callback) {

function run(item) {
iterator(_memo, item, (err, result) => {
if (err) {
throw new Error(err);
}
_memo = result;
next();
});
Expand Down

0 comments on commit 10573ab

Please sign in to comment.