From f80227ccd347e6666ca7bc473dfbdb1e72ec7dc1 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Thu, 4 May 2023 11:03:32 +0200 Subject: [PATCH] handle errors in dep, correctly catch missing url in version check replace console.error with throw to handle dep error failures in main try/catch to mark job as failed in one place --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index c87cad6..affece9 100644 --- a/index.js +++ b/index.js @@ -94,8 +94,8 @@ async function dep() { break } } - if (url === null) { - console.error(`The version "${version}"" does not exist in the "https://deployer.org/manifest.json" file."`) + if (typeof url === 'undefined') { + throw new Error(`The version "${version}"" does not exist in the "https://deployer.org/manifest.json" file."`) } else { console.log(`Downloading "${url}".`) await $`curl -LO ${url}` @@ -114,12 +114,12 @@ async function dep() { options.push('-o', `${key}=${value}`) } } catch (e) { - console.error('Invalid JSON in options') + throw new Error('Invalid JSON in options') } try { await $`php ${dep} ${cmd} --no-interaction ${ansi} ${verbosity} ${options}` } catch (err) { - core.setFailed(`Failed: dep ${cmd}`) + throw new Error(`Failed: dep ${cmd}`) } }