MCPcopy Create free account
hub / github.com/HELPMEEADICE/doge-code / classifyAPIError

Function classifyAPIError

src/services/api/errors.ts:975–1171  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

973 * Returns a standardized error type string suitable for Datadog tagging.
974 */
975export function classifyAPIError(error: unknown): string {
976 // Aborted requests
977 if (error instanceof Error && error.message === 'Request was aborted.') {
978 return 'aborted'
979 }
980
981 // Timeout errors
982 if (
983 error instanceof APIConnectionTimeoutError ||
984 (error instanceof APIConnectionError &&
985 error.message.toLowerCase().includes('timeout'))
986 ) {
987 return 'api_timeout'
988 }
989
990 // Check for repeated 529 errors
991 if (
992 error instanceof Error &&
993 error.message.includes(REPEATED_529_ERROR_MESSAGE)
994 ) {
995 return 'repeated_529'
996 }
997
998 // Check for emergency capacity off switch
999 if (
1000 error instanceof Error &&
1001 error.message.includes(CUSTOM_OFF_SWITCH_MESSAGE)
1002 ) {
1003 return 'capacity_off_switch'
1004 }
1005
1006 // Rate limiting
1007 if (error instanceof APIError && error.status === 429) {
1008 return 'rate_limit'
1009 }
1010
1011 // Server overload (529)
1012 if (
1013 error instanceof APIError &&
1014 (error.status === 529 ||
1015 error.message?.includes('"type":"overloaded_error"'))
1016 ) {
1017 return 'server_overload'
1018 }
1019
1020 // Prompt/content size errors
1021 if (
1022 error instanceof Error &&
1023 error.message
1024 .toLowerCase()
1025 .includes(PROMPT_TOO_LONG_ERROR_MESSAGE.toLowerCase())
1026 ) {
1027 return 'prompt_too_long'
1028 }
1029
1030 // PDF errors
1031 if (
1032 error instanceof Error &&

Callers 1

logAPIErrorFunction · 0.85

Calls 2

isEnvTruthyFunction · 0.85

Tested by

no test coverage detected