utils.ts 556 B

12345678910111213141516171819
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import {
  3. NotificationTypes,
  4. useNotifications,
  5. } from '#shared/components/CommonNotifications/index.ts'
  6. import UserError from '#shared/errors/UserError.ts'
  7. import type { ApolloError } from '@apollo/client/core'
  8. export const handleUserErrors = (error: UserError | ApolloError) => {
  9. if (error instanceof UserError) {
  10. useNotifications().notify({
  11. id: error.userErrorId,
  12. message: error.getFirstErrorMessage(),
  13. type: NotificationTypes.Error,
  14. })
  15. }
  16. }