Skip to content

Commit

Permalink
Log multiple errors
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
deejay1 authored and bigdaz committed Feb 6, 2024
1 parent 2572bdd commit 21bea8c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion dist/index.js
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion src/main.ts
Expand Up @@ -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}`)
Expand Down

0 comments on commit 21bea8c

Please sign in to comment.