Wrap JSON parse errors in parseMatrixInput with context

This commit is contained in:
Michael B. Gale
2026-09-22 18:46:55 +01:00
parent c0369726ee
commit 2294a7a8b1
2 changed files with 14 additions and 2 deletions

View File

@@ -894,7 +894,13 @@ export function parseMatrixInput(
if (matrixInput === undefined || matrixInput === "null") {
return undefined;
}
return JSON.parse(matrixInput) as { [key: string]: string };
try {
return JSON.parse(matrixInput) as { [key: string]: string };
} catch (err) {
throw new Error(
`Failed to parse matrix input '${matrixInput}': ${getErrorMessage(err)}`,
);
}
}
export function wrapError(error: unknown): Error {