appStoreValidationErrorMessage.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import * as Sentry from '@sentry/react';
  2. import Link from 'sentry/components/links/link';
  3. import {t, tct} from 'sentry/locale';
  4. import {AppStoreConnectValidationError} from 'sentry/types/debugFiles';
  5. export const unexpectedErrorMessage = t(
  6. 'An unexpected error occurred while configuring the App Store Connect integration'
  7. );
  8. export function getAppStoreValidationErrorMessage(
  9. error: AppStoreConnectValidationError,
  10. repo?: {link: string; name: string}
  11. ) {
  12. switch (error.code) {
  13. case 'app-connect-authentication-error':
  14. return repo
  15. ? tct(
  16. 'App Store Connect credentials are invalid or missing. [linkToCustomRepository]',
  17. {
  18. linkToCustomRepository: (
  19. <Link to={repo.link}>
  20. {tct(
  21. "Make sure the credentials of the '[customRepositoryName]' repository are correct and exist.",
  22. {
  23. customRepositoryName: repo.name,
  24. }
  25. )}
  26. </Link>
  27. ),
  28. }
  29. )
  30. : t('The supplied App Store Connect credentials are invalid or missing.');
  31. case 'app-connect-forbidden-error':
  32. return t('The supplied API key does not have sufficient permissions.');
  33. case 'app-connect-multiple-sources-error':
  34. return t('Only one App Store Connect application is allowed in this project.');
  35. default: {
  36. // this shall not happen
  37. Sentry.captureException(new Error('Unknown app store connect error.'));
  38. return unexpectedErrorMessage;
  39. }
  40. }
  41. }