MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / classifyError

Function classifyError

cosplay/cosplay.ts:49–60  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

47type RetryErrorType = "transient" | "permanent";
48
49function classifyError(error: unknown): RetryErrorType {
50 if (axios.isAxiosError(error)) {
51 const status = error.response?.status;
52 if (!status) {
53 return error.code === "ECONNABORTED" || error.code === "ETIMEDOUT"
54 ? "transient"
55 : "transient";
56 }
57 return status >= 500 || status === 429 ? "transient" : "permanent";
58 }
59 return "permanent";
60}
61
62async function withRetry<T>(
63 fn: () => Promise<T>,

Callers 1

withRetryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected