Skip to content

Commit

Permalink
Merge pull request #5440 from kiva/fix-cit-1921-refine-async-error-ha…
Browse files Browse the repository at this point in the history
…ndler

fix: extract async checkout error object with primary format
  • Loading branch information
mcstover authored Aug 13, 2024
2 parents 88d0eff + 8c586ff commit 0d2ebae
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/plugins/braintree-dropin-error-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import * as Sentry from '@sentry/vue';
export default {
methods: {
processBraintreeDropInError(trackCategory, kivaBraintreeResponse) {
// eslint-disable-next-line max-len
const errorCode = kivaBraintreeResponse.errors?.[0]?.extensions?.code ?? kivaBraintreeResponse.errors?.[0]?.error ?? 'UNKNOWN_ERROR_CODE';
const errorMessage = kivaBraintreeResponse.errors?.[0]?.message ?? JSON.stringify(kivaBraintreeResponse);
// extract error response
const errorObj = kivaBraintreeResponse?.[0] ?? kivaBraintreeResponse?.errors?.[0] ?? kivaBraintreeResponse;
// extract error code and message
const errorCode = errorObj?.extensions?.code ?? errorObj?.error ?? 'UNKNOWN_ERROR_CODE';
const errorMessage = errorObj?.message ?? JSON.stringify(kivaBraintreeResponse);
// eslint-disable-next-line max-len
const standardError = 'There was an error processing your payment. Please confirm your payment details and try again or contact our support team at <a href="mailto:contactus@kiva.org">contactus@kiva.org</a>.';

Expand All @@ -15,7 +17,7 @@ export default {
this.$kvTrackEvent(trackCategory, 'DropIn Payment Error', `${errorCode}: ${errorMessage}`);

// Log validation errors
Sentry.captureException(`${errorCode}:${errorMessage}`);
Sentry.captureException(`${errorCode}: ${errorMessage}`);
},
},
};

0 comments on commit 0d2ebae

Please sign in to comment.