Skip to content

Commit 8501675

Browse files
committed
add try block to prevent plugin from throwing jsonencode errors
1 parent 7cb6e57 commit 8501675

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

plugins/+testframework/TestResultsSummaryPlugin.m

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ function reportFinalizedSuite(plugin, pluginData)
2020
testResults = {};
2121
end
2222
testResults{end+1} = testDetails;
23-
JsonTestResults = jsonencode(testResults, "PrettyPrint", true);
2423

25-
[fID, msg] = fopen(testArtifactFile, "w");
26-
if fID == -1
27-
warning("testframework:TestResultsSummaryPlugin:UnableToOpenFile","Could not open a file for GitHub tests result table due to: %s", msg);
28-
else
29-
closeFile = onCleanup(@()fclose(fID));
30-
fprintf(fID, '%s', JsonTestResults);
24+
try
25+
JsonTestResults = jsonencode(testResults, "PrettyPrint", true);
26+
27+
[fID, msg] = fopen(testArtifactFile, "w");
28+
if fID == -1
29+
warning("testframework:TestResultsSummaryPlugin:UnableToOpenFile","Could not open a file for GitHub tests result table due to: %s", msg);
30+
else
31+
closeFile = onCleanup(@()fclose(fID));
32+
fprintf(fID, '%s', JsonTestResults);
33+
end
3134
end
3235

3336
% Invoke the superclass method

src/testResultsSummary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export function getTestResults(
114114
}
115115
} catch (e) {
116116
console.error(
117-
"An error occurred while reading the test results summary file ${resultsPath}:",
117+
`An error occurred while reading the test results summary file ${resultsPath}:`,
118118
e,
119119
);
120120
} finally {

0 commit comments

Comments
 (0)