From 0cfb8029c4f39b362c15c772f1555d435cbb38c9 Mon Sep 17 00:00:00 2001 From: Kevin Mayfield Date: Tue, 2 Jan 2024 07:19:21 +0000 Subject: [PATCH] Added try catch to file copy --- src/configureValidator.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/configureValidator.ts b/src/configureValidator.ts index 8b8bc90..bc95531 100644 --- a/src/configureValidator.ts +++ b/src/configureValidator.ts @@ -249,14 +249,17 @@ if (process.env.ONTO_URL != undefined) { if (dir.includes('MessageDefinition') || dir.includes('ObservationDefinition')) { destination = 'temp/package/examples/' + root + '.json'; } - - const resource: any = fs.readFileSync(dir + "/" + file, 'utf8'); - const json = getJson(file, resource); - fs.writeFile(destination, jsonminify(json), function (err) { - if (err) { - return console.error(err); - } - }); + try { + const resource: any = fs.readFileSync(dir + "/" + file, 'utf8'); + const json = getJson(file, resource); + fs.writeFile(destination, jsonminify(json), function (err) { + if (err) { + return console.error(err); + } + }); + } catch (e) { + console.error(e.message + ' Directory '+ dir + "/" + file) + } }) } else { console.info('INFO Folder not found ' + dir);