15 lines
458 B
TypeScript
15 lines
458 B
TypeScript
import { type ApolloError } from '@apollo/client';
|
|
import { t } from '@lingui/core/macro';
|
|
import { isDefined } from 'twenty-shared/utils';
|
|
|
|
export const getErrorMessageFromApolloError = (error: ApolloError): string => {
|
|
if (!isDefined(error.graphQLErrors?.[0]?.extensions?.userFriendlyMessage)) {
|
|
return t`An error occurred.`;
|
|
}
|
|
|
|
return (
|
|
(error.graphQLErrors[0].extensions?.userFriendlyMessage as string) ??
|
|
t`An error occurred.`
|
|
);
|
|
};
|