(e: unknown)
| 189 | * (disk full, permission denied) before flipping the git-fallback kill switch. |
| 190 | */ |
| 191 | export function classifyGcsError(e: unknown): string { |
| 192 | if (axios.isAxiosError(e)) { |
| 193 | if (e.code === 'ECONNABORTED') return 'timeout' |
| 194 | if (e.response) return `http_${e.response.status}` |
| 195 | return 'network' |
| 196 | } |
| 197 | const code = getErrnoCode(e) |
| 198 | // Node fs errno codes are E<UPPERCASE> (ENOSPC, EACCES). Axios also sets |
| 199 | // .code (ERR_NETWORK, ERR_BAD_OPTION, EPROTO) — don't bucket those as fs. |
| 200 | if (code && /^E[A-Z]+$/.test(code) && !code.startsWith('ERR_')) { |
| 201 | return KNOWN_FS_CODES.has(code) ? `fs_${code}` : 'fs_other' |
| 202 | } |
| 203 | // fflate sets numeric .code (0-14) on inflate/unzip errors — catches |
| 204 | // deflate-level corruption ("unexpected EOF", "invalid block type") that |
| 205 | // the message regex misses. |
| 206 | if (typeof (e as { code?: unknown })?.code === 'number') return 'zip_parse' |
| 207 | const msg = errorMessage(e) |
| 208 | if (/unzip|invalid zip|central directory/i.test(msg)) return 'zip_parse' |
| 209 | if (/empty body/.test(msg)) return 'empty_latest' |
| 210 | return 'other' |
| 211 | } |
no test coverage detected