MCPcopy Index your code
hub / github.com/codeaashu/claude-code / classifyFetchError

Function classifyFetchError

src/utils/plugins/fetchTelemetry.ts:108–135  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

106 * "timeout" — ordering the other way would misclassify git DNS as timeout.
107 */
108export 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

Callers 5

gitCloneFunction · 0.85
cacheMarketplaceFromGitFunction · 0.85
cacheMarketplaceFromUrlFunction · 0.85
downloadMcpbFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected