(errorInfo?: ErrorInfo, extractorId?: string)
| 286 | } |
| 287 | |
| 288 | export function extractErrorMessage(errorInfo?: ErrorInfo, extractorId?: string): string { |
| 289 | if (extractorId) { |
| 290 | return extractErrorMessageWithId(errorInfo, extractorId) |
| 291 | } |
| 292 | |
| 293 | // Backwards compatibility |
| 294 | for (const extractor of ERROR_EXTRACTORS) { |
| 295 | try { |
| 296 | const message = extractor.extract(errorInfo) |
| 297 | if (message?.trim()) { |
| 298 | return message |
| 299 | } |
| 300 | } catch (error) {} |
| 301 | } |
| 302 | |
| 303 | return `Request failed with status ${errorInfo?.status || 'unknown'}` |
| 304 | } |
| 305 | |
| 306 | export const ErrorExtractorId = { |
| 307 | ATLASSIAN_ERRORS: 'atlassian-errors', |
no test coverage detected