Skip to content

Commit

Permalink
chore: re-throw errors as AggregateErrors
Browse files Browse the repository at this point in the history
Keeps error stack traces.
  • Loading branch information
nikku committed Feb 10, 2021
1 parent 1980083 commit 12f22f9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const {
getOctokit
} = require('./recorder');

const AggregateError = require('aggregate-error');

const DEFAULT_MIN_APPROVALS = 1;

const CONFIG_FILE = 'merge-me.yml';
Expand Down Expand Up @@ -274,7 +276,7 @@ async function getCollaboratorReviews(context, pullRequest) {
continue;
}

throw error;
throw new AggregateError([ error ]);
}
}

Expand Down Expand Up @@ -687,7 +689,7 @@ async function merge(context, pullRequest) {

return false;
} else {
throw error;
throw new AggregateError([ error ]);
}
}
}
Expand Down Expand Up @@ -720,7 +722,7 @@ async function checkMerge(context, pullRequest) {
} else if (isMergeCheckError(error)) {
context.log.debug(ctx, `skipping: ${error.message}`);
} else {
throw error;
throw new AggregateError([ error ]);
}
}

Expand Down Expand Up @@ -950,7 +952,7 @@ async function getTeamsWithMembers(context, pullRequest, reviewTeams) {
throw MergeCheckError(`failed to fetch team ${teamSlug}`);
}

throw error;
throw new AggregateError([ error ]);
});

return members;
Expand Down
7 changes: 3 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"auto-test": "nodemon --exec npm test"
},
"dependencies": {
"aggregate-error": "^3.1.0",
"probot": "^10.19.0"
},
"devDependencies": {
Expand Down

0 comments on commit 12f22f9

Please sign in to comment.