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
This commit is contained in:
Piotr Kwiecinski 2023-05-04 11:03:32 +02:00
parent 363bb1be96
commit f80227ccd3

View file

@ -94,8 +94,8 @@ async function dep() {
break break
} }
} }
if (url === null) { if (typeof url === 'undefined') {
console.error(`The version "${version}"" does not exist in the "https://deployer.org/manifest.json" file."`) throw new Error(`The version "${version}"" does not exist in the "https://deployer.org/manifest.json" file."`)
} else { } else {
console.log(`Downloading "${url}".`) console.log(`Downloading "${url}".`)
await $`curl -LO ${url}` await $`curl -LO ${url}`
@ -114,12 +114,12 @@ async function dep() {
options.push('-o', `${key}=${value}`) options.push('-o', `${key}=${value}`)
} }
} catch (e) { } catch (e) {
console.error('Invalid JSON in options') throw new Error('Invalid JSON in options')
} }
try { try {
await $`php ${dep} ${cmd} --no-interaction ${ansi} ${verbosity} ${options}` await $`php ${dep} ${cmd} --no-interaction ${ansi} ${verbosity} ${options}`
} catch (err) { } catch (err) {
core.setFailed(`Failed: dep ${cmd}`) throw new Error(`Failed: dep ${cmd}`)
} }
} }