From d4d6125cf2e5750c715c4655dbddf35b2db6fa2b Mon Sep 17 00:00:00 2001 From: MaksimZhukov Date: Tue, 6 Dec 2022 17:07:51 +0100 Subject: [PATCH] Add try catch --- dist/setup/index.js | 22 +++++++++++++++------- src/utils.ts | 21 +++++++++++++-------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index a022c17b..7d58fa84 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -67089,16 +67089,24 @@ function getLinuxInfo() { function getOSInfo() { return __awaiter(this, void 0, void 0, function* () { let osInfo; - if (exports.IS_WINDOWS) { - osInfo = yield getWindowsInfo(); + try { + if (exports.IS_WINDOWS) { + osInfo = yield getWindowsInfo(); + } + else if (exports.IS_LINUX) { + osInfo = yield getLinuxInfo(); + } + else if (exports.IS_MAC) { + osInfo = yield getMacOSInfo(); + } } - else if (exports.IS_LINUX) { - osInfo = yield getLinuxInfo(); + catch (err) { + const error = err; + core.debug(error.message); } - else if (exports.IS_MAC) { - osInfo = yield getMacOSInfo(); + finally { + return osInfo; } - return osInfo; }); } exports.getOSInfo = getOSInfo; diff --git a/src/utils.ts b/src/utils.ts index e500d631..e5230904 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -179,13 +179,18 @@ async function getLinuxInfo() { export async function getOSInfo() { let osInfo; - if (IS_WINDOWS) { - osInfo = await getWindowsInfo(); - } else if (IS_LINUX) { - osInfo = await getLinuxInfo(); - } else if (IS_MAC) { - osInfo = await getMacOSInfo(); + try { + if (IS_WINDOWS) { + osInfo = await getWindowsInfo(); + } else if (IS_LINUX) { + osInfo = await getLinuxInfo(); + } else if (IS_MAC) { + osInfo = await getMacOSInfo(); + } + } catch (err) { + const error = err as Error; + core.debug(error.message); + } finally { + return osInfo; } - - return osInfo; }