(error: unknown)
| 106 | * "timeout" — ordering the other way would misclassify git DNS as timeout. |
| 107 | */ |
| 108 | export function classifyFetchError(error: unknown): string { |
| 109 | const msg = String((error as { message?: unknown })?.message ?? error) |
| 110 | if ( |
| 111 | /ENOTFOUND|ECONNREFUSED|EAI_AGAIN|Could not resolve host|Connection refused/i.test( |
| 112 | msg, |
| 113 | ) |
| 114 | ) { |
| 115 | return 'dns_or_refused' |
| 116 | } |
| 117 | if (/ETIMEDOUT|timed out|timeout/i.test(msg)) return 'timeout' |
| 118 | if ( |
| 119 | /ECONNRESET|socket hang up|Connection reset by peer|remote end hung up/i.test( |
| 120 | msg, |
| 121 | ) |
| 122 | ) { |
| 123 | return 'conn_reset' |
| 124 | } |
| 125 | if (/403|401|authentication|permission denied/i.test(msg)) return 'auth' |
| 126 | if (/404|not found|repository not found/i.test(msg)) return 'not_found' |
| 127 | if (/certificate|SSL|TLS|unable to get local issuer/i.test(msg)) return 'tls' |
| 128 | // Schema validation throws "Invalid response format" (install_counts) — |
| 129 | // distinguish from true unknowns so the dashboard can |
| 130 | // see "server sent garbage" separately. |
| 131 | if (/Invalid response format|Invalid marketplace schema/i.test(msg)) { |
| 132 | return 'invalid_schema' |
| 133 | } |
| 134 | return 'other' |
| 135 | } |
| 136 |
no outgoing calls
no test coverage detected