diff --git a/frontend/src/config/integrations/gerrit/components/gerrit-settings-drawer.vue b/frontend/src/config/integrations/gerrit/components/gerrit-settings-drawer.vue index a71d89e099..b0de5d0007 100644 --- a/frontend/src/config/integrations/gerrit/components/gerrit-settings-drawer.vue +++ b/frontend/src/config/integrations/gerrit/components/gerrit-settings-drawer.vue @@ -119,6 +119,9 @@ import { Platform } from '@/shared/modules/platform/types/Platform'; import LfIcon from '@/ui-kit/icon/Icon.vue'; import LfButton from '@/ui-kit/button/Button.vue'; import LfCheckbox from '@/ui-kit/checkbox/Checkbox.vue'; +import { parseDuplicateRepoError, customRepoErrorMessage } from '@/shared/helpers/error-message.helper'; +import { IntegrationService } from '@/modules/integration/integration-service'; +import { ToastStore } from '@/shared/message/notification'; const emit = defineEmits(['update:modelValue']); const props = defineProps<{ @@ -192,6 +195,7 @@ const connect = async () => { enableGit: form.enableGit, segmentId: props.segmentId, grandparentId: props.grandparentId, + errorHandler, }) .then(() => { trackEvent({ @@ -210,6 +214,23 @@ const connect = async () => { loading.value = false; }); }; + +const errorHandler = (error: any) => { + const errorMessage = error?.response?.data; + const parsedError = parseDuplicateRepoError(errorMessage, 'There was an error mapping gerrit repositories'); + + if (parsedError) { + const { repo, eId } = parsedError; + // TODO: This is returning 404 error for some reason. It could be that the data returned by the error is incorrect. + IntegrationService.find(eId) + .then((integration) => { + customRepoErrorMessage(integration.segment, repo, 'gerrit'); + }) + .catch(() => { + ToastStore.error(errorMessage); + }); + } +};