(err: any)
| 5 | * Show common error toast with auto process error object |
| 6 | */ |
| 7 | export function showErrorToast(err: any) { |
| 8 | console.error(err); |
| 9 | |
| 10 | if (err instanceof TRPCClientError) { |
| 11 | try { |
| 12 | const json = JSON.parse(err.message); |
| 13 | toast.error(json[0].message); |
| 14 | } catch { |
| 15 | toast.error(err.message); |
| 16 | } |
| 17 | |
| 18 | return; |
| 19 | } |
| 20 | |
| 21 | if (err instanceof Error) { |
| 22 | toast.error(err.message); |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | toast.error(String(err)); |
| 27 | } |
no test coverage detected