Wrap JSON parse errors in cloneObject with context

This commit is contained in:
Michael B. Gale
2026-09-22 18:52:03 +01:00
parent 2294a7a8b1
commit 8e36092a16
2 changed files with 10 additions and 2 deletions

View File

@@ -1043,7 +1043,11 @@ export enum BuildMode {
}
export function cloneObject<T>(obj: T): T {
return JSON.parse(JSON.stringify(obj)) as T;
try {
return JSON.parse(JSON.stringify(obj)) as T;
} catch (err) {
throw new Error(`Cloning object failed: ${getErrorMessage(err)}`);
}
}
export async function cleanUpPath(file: string, name: string, logger: Logger) {