Log multiple errors

# What
Log AggregateError type, when multiple errors are returned
from HTTP client - fixes #174

# Why
We would silently fail otherwise as error.message was empty
for the AggregatedError exception.
This commit is contained in:
Łukasz Jernaś 2024-02-06 15:50:29 +01:00 committed by daz
parent 2572bdd97b
commit 21bea8c867
No known key found for this signature in database
2 changed files with 13 additions and 2 deletions

8
dist/index.js vendored
View file

@ -28027,7 +28027,13 @@ async function run() {
}
}
catch (error) {
if (error instanceof 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 {

View file

@ -25,7 +25,12 @@ export async function run(): Promise<void> {
}
}
} catch (error) {
if (error instanceof 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}`)