| 123456789101112131415161718192021222324 |
- import { AxiosError } from 'axios'
- import { toast } from 'sonner'
- export function handleServerError(error: unknown) {
- // eslint-disable-next-line no-console
- console.log(error)
- let errMsg = 'Something went wrong!'
- if (
- error &&
- typeof error === 'object' &&
- 'status' in error &&
- Number(error.status) === 204
- ) {
- errMsg = 'Content not found.'
- }
- if (error instanceof AxiosError) {
- errMsg = error.response?.data.title
- }
- toast.error(errMsg)
- }
|