From 085e38d2d350a43668784304194619eddf4d5d7c Mon Sep 17 00:00:00 2001 From: Jonas Bovin Date: Fri, 9 Dec 2022 11:59:59 +0100 Subject: [PATCH] Added error handling --- dist/index.js | 20 ++++++++++++++++---- src/se.ts | 19 +++++++++++++++---- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/dist/index.js b/dist/index.js index f446188..bdcd7e1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -13636,10 +13636,22 @@ class se_Helper { createMetaJson(root) { const execSync = external_child_process_.execSync; console.log('Run number: ' + this.currentBuild.runNumber); - const xmllint = execSync('sudo apt install libxml2-utils', { - shell: '/bin/bash' - }); - console.log(xmllint.toString()); + try { + const xmllint = execSync('sudo apt install libxml2-utils', { + shell: '/bin/bash' + }); + console.log(xmllint.toString()); + } + catch (err) { + let message; + if (err instanceof Error) { + message = err.message; + } + else { + message = String(err); + } + console.log(message); + } const ret = []; const poms = this.listPoms(root); const ownersFile = Object(external_fs_.readFileSync)(root + '.github/CODEOWNERS', 'utf8') diff --git a/src/se.ts b/src/se.ts index 16d0779..cd54d8a 100644 --- a/src/se.ts +++ b/src/se.ts @@ -46,10 +46,21 @@ export class Helper { public createMetaJson(root: string) { const execSync = child.execSync console.log('Run number: ' + this.currentBuild.runNumber) - const xmllint = execSync('sudo apt install libxml2-utils', { - shell: '/bin/bash' - }) - console.log(xmllint.toString()) + try { + const xmllint = execSync('sudo apt install libxml2-utils', { + shell: '/bin/bash' + }) + + console.log(xmllint.toString()) + } catch (err) { + let message + if (err instanceof Error) { + message = err.message + } else { + message = String(err) + } + console.log(message) + } const ret: string[] = [] const poms = this.listPoms(root) const ownersFile = fs