( errorInfo: ErrorInfo | undefined, extractorId: string )
| 266 | const EXTRACTOR_MAP = new Map<string, ErrorExtractorConfig>(ERROR_EXTRACTORS.map((e) => [e.id, e])) |
| 267 | |
| 268 | export function extractErrorMessageWithId( |
| 269 | errorInfo: ErrorInfo | undefined, |
| 270 | extractorId: string |
| 271 | ): string { |
| 272 | const extractor = EXTRACTOR_MAP.get(extractorId) |
| 273 | |
| 274 | if (!extractor) { |
| 275 | return `Request failed with status ${errorInfo?.status || 'unknown'}` |
| 276 | } |
| 277 | |
| 278 | try { |
| 279 | const message = extractor.extract(errorInfo) |
| 280 | if (message?.trim()) { |
| 281 | return message |
| 282 | } |
| 283 | } catch (error) {} |
| 284 | |
| 285 | return `Request failed with status ${errorInfo?.status || 'unknown'}` |
| 286 | } |
| 287 | |
| 288 | export function extractErrorMessage(errorInfo?: ErrorInfo, extractorId?: string): string { |
| 289 | if (extractorId) { |
no test coverage detected