review-comments: nest validateSariFileSchema into try-catch block to better discriminate error thrown
This commit is contained in:
parent
498c7f37e8
commit
676a422916
6 changed files with 25 additions and 24 deletions
14
lib/upload-lib.js
generated
14
lib/upload-lib.js
generated
|
|
@ -410,9 +410,17 @@ async function uploadFiles(sarifPath, checkoutPath, category, features, logger)
|
|||
logger.startGroup("Uploading results");
|
||||
logger.info(`Processing sarif files: ${JSON.stringify(sarifFiles)}`);
|
||||
const gitHubVersion = await (0, api_client_1.getGitHubVersion)();
|
||||
// Validate that the files we were asked to upload are all valid SARIF files
|
||||
for (const file of sarifFiles) {
|
||||
validateSarifFileSchema(file, logger);
|
||||
try {
|
||||
// Validate that the files we were asked to upload are all valid SARIF files
|
||||
for (const file of sarifFiles) {
|
||||
validateSarifFileSchema(file, logger);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof SyntaxError) {
|
||||
throw new InvalidSarifUploadError(e.message);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
let sarif = await combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, logger);
|
||||
sarif = filterAlertsByDiffRange(logger, sarif);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue