Skip to content

Commit

Permalink
chore: simplified condition for error throw on pull-request
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Jan 29, 2025
1 parent 77bcff0 commit 70ea38b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/handlers/user-start-stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,12 @@ export async function userPullRequest(context: Context<"pull_request.opened" | "
try {
return await start(context, issueWithComment, pull_request.user ?? payload.sender, []);
} catch (error) {
if (error instanceof AggregateError) {
if (!error.errors.some((e) => e instanceof PricingError)) {
await closePullRequest(context, { number: pull_request.number });
throw context.logger.error(error.errors.map((o) => String(o)).join("\n"), { error: error as Error });
}
} else {
// We want to close the pull-request only if the PricingError is not present
if (!(error instanceof AggregateError) || !error.errors.some((e) => e instanceof PricingError)) {
await closePullRequest(context, { number: pull_request.number });
throw error;
}
// Makes sure to concatenate error messages on AggregateError for proper display
throw error instanceof AggregateError ? context.logger.error(error.errors.map(String).join("\n"), { error }) : error;
}
}
}
Expand Down

0 comments on commit 70ea38b

Please sign in to comment.