Skip to content

Commit eb1ce2b

Browse files
committed
feat: make sure to use message for parse opportunity as fallback
1 parent 3b74a4b commit eb1ce2b

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

packages/shared/src/features/opportunity/mutations.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type {
55
ApiZodErrorExtension,
66
} from '../../graphql/common';
77
import { gqlClient, ApiError } from '../../graphql/common';
8-
import { labels } from '../../lib';
98
import {
109
ACCEPT_OPPORTUNITY_MATCH,
1110
ADD_OPPORTUNITY_SEATS_MUTATION,
@@ -474,7 +473,13 @@ export const getParseOpportunityMutationErrorMessage = (
474473
);
475474
}
476475

477-
return error?.response?.errors?.[0]?.message || labels.error.generic;
476+
if (error?.response?.errors?.[0]?.extensions?.code === ApiError.Unexpected) {
477+
return PARSE_OPPORTUNITY_ERROR_MESSAGE;
478+
}
479+
480+
return (
481+
error?.response?.errors?.[0]?.message || PARSE_OPPORTUNITY_ERROR_MESSAGE
482+
);
478483
};
479484

480485
export const parseOpportunityMutationOptions = () => {

packages/shared/src/graphql/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export enum ApiError {
115115
ZodValidationError = 'ZOD_VALIDATION_ERROR',
116116
Conflict = 'CONFLICT',
117117
PaymentRequired = 'PAYMENT_REQUIRED',
118+
Unexpected = 'UNEXPECTED',
118119
}
119120

120121
export enum ApiErrorMessage {

0 commit comments

Comments
 (0)