Skip to content

Commit

Permalink
chore: better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
murtuzaalisurti committed Sep 23, 2024
1 parent 29ad593 commit c6d7a65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60067,6 +60067,7 @@ async function getSuggestions({ platform, rawComments, platformSDK, rules, model
error(`Could not generate suggestions: ${err.message}`);
core.setFailed(`Could not generate suggestions: ${err.message}`);
}
return null;
}
}

Expand Down Expand Up @@ -60273,7 +60274,12 @@ async function run() {
},
});

if (suggestions?.commentsToAdd.length === 0) {
if (!suggestions) {
warning("Could not generate suggestions. Refer to the error log for more information and try again.");
return;
}

if (suggestions.commentsToAdd.length === 0) {
info("No suggestions found. Code review complete. All good!");
return;
}
Expand Down
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ async function getSuggestions({ platform, rawComments, platformSDK, rules, model
error(`Could not generate suggestions: ${err.message}`);
core.setFailed(`Could not generate suggestions: ${err.message}`);
}
return null;
}
}

Expand Down Expand Up @@ -478,7 +479,12 @@ async function run() {
},
});

if (suggestions?.commentsToAdd.length === 0) {
if (!suggestions) {
warning("Could not generate suggestions. Refer to the error log for more information and try again.");
return;
}

if (suggestions.commentsToAdd.length === 0) {
info("No suggestions found. Code review complete. All good!");
return;
}
Expand Down

0 comments on commit c6d7a65

Please sign in to comment.