import axios, { type AxiosError } from 'axios'; import clsx from 'clsx'; import { external_urls } from '@/utils/constants'; import { isResponseHtml } from '@/utils/utils'; import PrettyJson from '../ui/PrettyJSON'; import TextURL from '../ui/TextURL'; import AnimateFade from '../wrap/AnimateFade'; export type ErrorData = string | Error | AxiosError | undefined; interface InfoErrorProps { error: ErrorData; } function DescribeError({ error }: { error: ErrorData }) { if (!error) { return

Ошибки отсутствуют

; } else if (typeof error === 'string') { return

{error}

; } else if (!axios.isAxiosError(error)) { return ; } if (!error?.response) { return

Нет ответа от сервера

; } if (error.response.status === 404) { return (

{'Обращение к несуществующему API'}

); } if (error.response.status === 403 && error.message.includes('CSRF')) { return (

{'Соединение с сервером потеряно. Перезагрузите страницу'}

); } // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call const isHtml = isResponseHtml(error.response); return (

Ошибка

{error.message}

{error.response.data && ( <>

Описание

{isHtml ?
: null} {!isHtml ? : null} )}
); } function InfoError({ error }: InfoErrorProps) { return (

Пожалуйста сделайте скриншот и отправьте вместе с описанием ситуации на почту{' '}
Для продолжения работы перезагрузите страницу

); } export default InfoError;