Skip to content

Commit

Permalink
Return promise from next()
Browse files Browse the repository at this point in the history
This will allow users to define middleware that can handle rejections from
promises within middleware/calls/casts
  • Loading branch information
Brendan Myers committed Feb 23, 2017
1 parent bca0e7f commit 4e1f14b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,15 @@ export default class Worker {
return this._middlewares[i](
request,
response,
() => { this._execCallback(i+1, request, response, last) }
() => {
return new Promise((resolve, reject) => {
try {
resolve(this._execCallback(i+1, request, response, last));
} catch (error) {
reject(error);
}
});
}
);
}
}

0 comments on commit 4e1f14b

Please sign in to comment.