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
}
}
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}`)
}
}