Skip to content

Commit

Permalink
fix: throw error for nonzero exit code, after posting (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
typpo authored Feb 21, 2024
1 parent 2c774ac commit 831a73d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
13 changes: 6 additions & 7 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,12 @@ export async function run(): Promise<void> {
...(vertexApiKey ? {VERTEX_API_KEY: vertexApiKey} : {}),
...(cachePath ? {PROMPTFOO_CACHE_PATH: cachePath} : {}),
};
let errorToThrow: Error | undefined;
try {
await exec.exec(`npx promptfoo@${version}`, promptfooArgs, {env});
} catch (error) {
// Ignore nonzero exit code
if (error instanceof Error) {
core.info(`promptfoo exited with error: ${error.message}`);
} else {
core.info(`promptfoo exited with an unknown error.`);
}
// Ignore nonzero exit code, but save the error to throw later
errorToThrow = error as Error;
}

// Comment PR
Expand All @@ -179,6 +176,10 @@ export async function run(): Promise<void> {
issue_number: pullRequest.number,
body,
});

if (errorToThrow) {
throw errorToThrow;
}
} catch (error) {
if (error instanceof Error) {
handleError(error);
Expand Down

0 comments on commit 831a73d

Please sign in to comment.