пва
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user