(error: unknown)
| 41 | * literals in thunk .catch callbacks) instead of dispatching via handleApiError. |
| 42 | */ |
| 43 | export function extractErrorMessage(error: unknown): string { |
| 44 | if (error instanceof ApiRequestError) { |
| 45 | return getErrorMessage(error.apiError); |
| 46 | } |
| 47 | if (error instanceof Error) { |
| 48 | return error.message; |
| 49 | } |
| 50 | if (isSerializedError(error)) { |
| 51 | return error.message; |
| 52 | } |
| 53 | return String(error); |
| 54 | } |
| 55 | |
| 56 | export interface HandleApiErrorOptions { |
| 57 | /** When true, do not dispatch to MessageSnackbar. */ |
no test coverage detected