MCPcopy
hub / github.com/CodebuffAI/codebuff / getRetryableErrorDescription

Function getRetryableErrorDescription

packages/internal/src/db/transaction.ts:126–153  ·  view source on GitHub ↗
(
  error: unknown,
)

Source from the content-addressed store, hash-verified

124 * Returns the error description if retryable, null otherwise.
125 */
126export function getRetryableErrorDescription(
127 error: unknown,
128): string | null {
129 const errorCode = getPostgresErrorCode(error)
130 if (typeof errorCode !== 'string') {
131 return null
132 }
133
134 // Check exact match first
135 if (errorCode in RETRYABLE_PG_ERROR_CODES) {
136 return RETRYABLE_PG_ERROR_CODES[errorCode]
137 }
138
139 // Check class-level match (first 2 characters) for retryable error classes
140 // This catches any errors in these classes we may not have explicitly listed
141 const errorClass = errorCode.substring(0, 2)
142 const retryableClasses: Record<string, string> = {
143 '08': 'connection_exception',
144 '40': 'transaction_rollback',
145 '53': 'insufficient_resources',
146 '57': 'operator_intervention',
147 }
148 if (errorClass in retryableClasses) {
149 return `${retryableClasses[errorClass]}_${errorCode}`
150 }
151
152 return null
153}
154
155/**
156 * Checks if an error is a retryable PostgreSQL error.

Callers 4

isRetryablePostgresErrorFunction · 0.85

Calls 1

getPostgresErrorCodeFunction · 0.85

Tested by

no test coverage detected