2026-01-02 13:41:09 +00:00
|
|
|
// Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
|
2024-08-16 10:30:32 +00:00
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
NotificationTypes,
|
|
|
|
|
useNotifications,
|
|
|
|
|
} from '#shared/components/CommonNotifications/index.ts'
|
|
|
|
|
import UserError from '#shared/errors/UserError.ts'
|
|
|
|
|
|
|
|
|
|
import type { ApolloError } from '@apollo/client/core'
|
|
|
|
|
|
|
|
|
|
export const handleUserErrors = (error: UserError | ApolloError) => {
|
|
|
|
|
if (error instanceof UserError) {
|
|
|
|
|
useNotifications().notify({
|
|
|
|
|
id: error.userErrorId,
|
|
|
|
|
message: error.getFirstErrorMessage(),
|
|
|
|
|
type: NotificationTypes.Error,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|