Consolidate error processing in actions

This commit is contained in:
daz
2024-04-11 10:18:07 -06:00
parent 1c25312b02
commit ba79f71e36
6 changed files with 42 additions and 52 deletions

View File

@@ -2,6 +2,7 @@ import * as path from 'path'
import * as core from '@actions/core'
import * as validate from './validate'
import {handleMainActionError} from '../errors'
export async function run(): Promise<void> {
try {
@@ -22,16 +23,7 @@ export async function run(): Promise<void> {
}
}
} catch (error) {
if (error instanceof AggregateError) {
core.setFailed(`Multiple errors returned`)
for (const err of error.errors) {
core.error(`Error ${error.errors.indexOf(err)}: ${err.message}`)
}
} else if (error instanceof Error) {
core.setFailed(error.message)
} else {
core.setFailed(`Unknown object was thrown: ${error}`)
}
handleMainActionError(error)
}
}