Skip to content

Commit

Permalink
Switch to preserved error case
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgauntseo-sentry committed Jul 28, 2023
1 parent 06f3911 commit 06ecae2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/api/github/getRelevantCommit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { GETSENTRY_ORG, GETSENTRY_REPO_SLUG, SENTRY_REPO_SLUG } from '@/config';
* In this case, it will return the sentry commit.
*/
export async function getRelevantCommit(ref: string) {
// Create an error object here before we make any async calls so that we
// have a helpful stack trace if it errors
const preservedError = new Error('getRelevantCommit Error');

try {
// Attempt to get the getsentry commit first
const { data: commit } = await GETSENTRY_ORG.api.repos.getCommit({
Expand Down Expand Up @@ -43,7 +47,7 @@ export async function getRelevantCommit(ref: string) {
return data;
} catch (err) {
console.error('Failed to get relevant commits:', err);
Sentry.captureException(err);
Sentry.captureException(preservedError, err);
return null;
}
}
6 changes: 5 additions & 1 deletion src/brain/notifyOnGoCDStageEvent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ export async function handler(resBody: GoCDResponse) {
});
Sentry.configureScope((scope) => scope.setSpan(tx));

// Create an error object here before we make any async calls so that we
// have a helpful stack trace if it errors
const preservedError = new Error('notifyOnGoCDStageEvent Error');

// Get the range of commits for this payload
try {
const latestDeploy = await getLastGetSentryGoCDDeploy(
Expand All @@ -286,7 +290,7 @@ export async function handler(resBody: GoCDResponse) {
]);
} catch (err) {
console.error('Failed to get notify on GoCD stage event:', err);
Sentry.captureException(err);
Sentry.captureException(preservedError, err);
} finally {
tx.finish();
}
Expand Down

0 comments on commit 06ecae2

Please sign in to comment.