Skip to content

Commit

Permalink
Handle rejections in migration actions (#148)
Browse files Browse the repository at this point in the history
Before they were resulting in unhandled rejection errors!
  • Loading branch information
alem0lars authored and dolezel committed Jan 11, 2018
1 parent 47da19f commit e7db5dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ class Migration {
}

_apply(action, pgm) {
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
if (action.length === 2) {
action(pgm, resolve);
} else {
const result = action(pgm);
// result conforms to Promises/A+ spec
if (typeof result === 'object' && typeof result.then === 'function') {
result.then(resolve);
result.then(resolve).catch(err => reject(err));
} else {
resolve();
}
Expand Down

0 comments on commit e7db5dc

Please sign in to comment.