Error handling for JSON parsing
This commit is contained in:
parent
6630cbeccb
commit
8a4a573d59
3 changed files with 17 additions and 6 deletions
11
lib/actions-util.js
generated
11
lib/actions-util.js
generated
|
|
@ -688,9 +688,14 @@ async function uploadDebugArtifacts(toUpload, rootDir, artifactName) {
|
|||
}
|
||||
let suffix = "";
|
||||
const matrix = getRequiredInput("matrix");
|
||||
if (matrix !== undefined && matrix !== "null") {
|
||||
for (const entry of Object.entries(JSON.parse(matrix)).sort())
|
||||
suffix += `-${entry[1]}`;
|
||||
if (matrix) {
|
||||
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}`), toUpload.map((file) => path.normalize(file)), path.normalize(rootDir));
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -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}`),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue