Error handling for JSON parsing

This commit is contained in:
Angela P Wen 2022-08-01 12:12:49 +02:00
parent 6630cbeccb
commit 8a4a573d59
3 changed files with 17 additions and 6 deletions

View file

@ -888,8 +888,14 @@ export async function uploadDebugArtifacts(
let suffix = "";
const matrix = getRequiredInput("matrix");
if (matrix) {
for (const [, matrixVal] of Object.entries(JSON.parse(matrix)).sort())
suffix += `-${matrixVal}`;
try {
for (const [, matrixVal] of Object.entries(JSON.parse(matrix)).sort())
suffix += `-${matrixVal}`;
} catch (e) {
core.info(
"Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input."
);
}
}
await artifact.create().uploadArtifact(
sanitizeArifactName(`${artifactName}${suffix}`),