This commit is contained in:
Kirill
2026-05-22 23:44:48 +05:00
parent bb78782b39
commit 7e5ed9cefa
3 changed files with 6 additions and 1 deletions
@@ -1,4 +1,8 @@
export function getErrorMessage(error: unknown, fallback = 'Произошла ошибка'): string {
if (error && typeof error === 'object' && 'response' in error) {
const axiosErr = error as { response?: { data?: { error?: string } } }
if (axiosErr.response?.data?.error) return axiosErr.response.data.error
}
if (error instanceof Error && error.message) return error.message
return fallback
}