Skip to content

Commit

Permalink
... again.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-corbalt committed Mar 7, 2024
1 parent 2b655b9 commit 1bbccb0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 62 deletions.
56 changes: 19 additions & 37 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 3 additions & 21 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,9 @@ async function run(): Promise<void> {
epicKey: process.env.JIRA_EPIC_KEY,
customJiraFields
}).sync();
//} catch (e: unknown) {
// core.setFailed(`Sync failed: ${e}`);
//}
} catch (error: unknown) {
// Create a function to extract error message(s)
const extractErrorMessage = (err: unknown): string => {
if (err instanceof AggregateError) {
// Map each error in the AggregateError to its message and join them
return err.errors.map(extractErrorMessage).join("; ");
} else if (err instanceof Error) {
return err.message;
} else {
// Fallback for anything that's not an Error or AggregateError
return String(err);
}
};

// Use the function to extract the message from the caught error
const errorMessage = extractErrorMessage(error);
throw new Error(`Sync failed: ${errorMessage}`);
}
} catch (e: any) {
core.setFailed(`Sync failed: ${e.message}`);
}
}

run();
8 changes: 4 additions & 4 deletions src/libs/jira-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class Jira {
let total = 0;

do {
//try {
try {
const response = await this.axiosInstance.post('/rest/api/2/search', {
jql: fullQuery,
startAt: startAt,
Expand All @@ -155,10 +155,10 @@ export class Jira {
totalIssuesReceived += results.issues.length;
startAt = totalIssuesReceived;
total = results.total;
//} catch (error) {
//throw new Error(`Error getting Security Hub issues from Jira: ${error}`);
} catch (error) {
throw new Error(`Error getting Security Hub issues from Jira: ${error}`);
//throw new Error(`Error getting Security Hub issues from Jira: ${error instanceof AggregateError ? error.message : error}`);
//}
}
} while (totalIssuesReceived < total);

return allIssues;
Expand Down

0 comments on commit 1bbccb0

Please sign in to comment.