Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

1.1 KB
Raw Blame
import { Flex, Text } from '@invoke-ai/ui-library';
import { ExternalLink } from 'features/gallery/components/ImageViewer/NoContentForViewer';
import { t } from 'i18next';
import { useMemo } from 'react';
import { Trans } from 'react-i18next';

type DescriptionProps = { errorType: string; errorMessage?: string | null };

export const getTitle = (errorType: string) => {
  return errorType === 'OutOfMemoryError' ? t('toast.outOfMemoryError') : t('toast.serverError');
};

export default function ErrorToastDescription({ errorType, errorMessage }: DescriptionProps) {
  const description = useMemo(() => {
    if (errorType === 'OutOfMemoryError') {
      return (
        <Trans
          i18nKey="toast.outOfMemoryErrorDescLocal"
          components={{
            LinkComponent: <ExternalLink href="https://invoke.ai/configuration/low-vram-mode/" />,
          }}
        />
      );
    } else if (errorMessage) {
      return `${errorType}: ${errorMessage}`;
    }
  }, [errorMessage, errorType]);

  return (
    <Flex flexDir="column">
      <Text noOfLines={4} fontSize="md">
        {description}
      </Text>
    </Flex>
  );
}