Skip to content

Commit

Permalink
Merge pull request #127 from guardian/aa/more-directed-error-handling
Browse files Browse the repository at this point in the history
feat: Handle Riff-Raff upload error, and PR commenting error separately
  • Loading branch information
akash1810 authored Apr 26, 2024
2 parents 8bedd7c + 323f02a commit b2107fa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
11 changes: 8 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59071,6 +59071,13 @@ var main = async (options) => {
keyPrefix + "/build.json"
);
core4.info("Upload complete.");
} catch (err) {
core4.error(
"Error uploading to Riff-Raff. Does the repository have an IAM Role? See https://github.com/guardian/riffraff-platform"
);
throw err;
}
try {
const pullRequestNumber = await getPullRequestNumber(pullRequestComment);
if (pullRequestNumber) {
core4.info(`Commenting on PR ${pullRequestNumber}`);
Expand All @@ -59081,9 +59088,7 @@ var main = async (options) => {
);
}
} catch (err) {
core4.error(
"Error uploading to Riff-Raff. Does the repository have an IAM Role? See https://github.com/guardian/riffraff-platform"
);
core4.error("Error commenting on PR. Do you have the correct permissions?");
throw err;
}
};
Expand Down
19 changes: 11 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,16 @@ export const main = async (options: Options): Promise<void> => {
);

core.info('Upload complete.');
} catch (err) {
core.error(
'Error uploading to Riff-Raff. Does the repository have an IAM Role? See https://github.com/guardian/riffraff-platform',
);

// throw to fail the action
throw err;
}

try {
const pullRequestNumber = await getPullRequestNumber(pullRequestComment);
if (pullRequestNumber) {
core.info(`Commenting on PR ${pullRequestNumber}`);
Expand All @@ -144,15 +153,9 @@ export const main = async (options: Options): Promise<void> => {
);
}
} catch (err) {
core.error(
'Error uploading to Riff-Raff. Does the repository have an IAM Role? See https://github.com/guardian/riffraff-platform',
);
core.error('Error commenting on PR. Do you have the correct permissions?');

/*
We've caught every exception, not just AWS credential errors.
Re-throw it so that GHA can handle it.
TODO: Catch a more specific error type.
*/
// throw to fail the action
throw err;
}
};
Expand Down

0 comments on commit b2107fa

Please sign in to comment.