(error: unknown)
| 149 | * @returns A user-friendly error message |
| 150 | */ |
| 151 | export function getErrorMessage(error: unknown): string { |
| 152 | if (error instanceof ImportError) { |
| 153 | return error.message |
| 154 | } |
| 155 | |
| 156 | if (error instanceof Error) { |
| 157 | if (error.name === 'TimeoutError' || error.name === 'AbortError') { |
| 158 | return 'Request timed out. Please try again.' |
| 159 | } |
| 160 | if (error.message.includes('fetch') || error.message.includes('ENOTFOUND')) { |
| 161 | return 'Failed to connect to Deepnote. Check your internet connection and try again.' |
| 162 | } |
| 163 | return error.message |
| 164 | } |
| 165 | |
| 166 | return 'An unknown error occurred' |
| 167 | } |
no outgoing calls
no test coverage detected