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

Function handleErrorStatus

src/bridge/bridgeApi.ts:454–500  ·  view source on GitHub ↗
(
  status: number,
  data: unknown,
  context: string,
)

Source from the content-addressed store, hash-verified

452}
453
454function handleErrorStatus(
455 status: number,
456 data: unknown,
457 context: string,
458): void {
459 if (status === 200 || status === 204) {
460 return
461 }
462 const detail = extractErrorDetail(data)
463 const errorType = extractErrorTypeFromData(data)
464 switch (status) {
465 case 401:
466 throw new BridgeFatalError(
467 `${context}: Authentication failed (401)${detail ? `: ${detail}` : ''}. ${BRIDGE_LOGIN_INSTRUCTION}`,
468 401,
469 errorType,
470 )
471 case 403:
472 throw new BridgeFatalError(
473 isExpiredErrorType(errorType)
474 ? 'Remote Control session has expired. Please restart with `claude remote-control` or /remote-control.'
475 : `${context}: Access denied (403)${detail ? `: ${detail}` : ''}. Check your organization permissions.`,
476 403,
477 errorType,
478 )
479 case 404:
480 throw new BridgeFatalError(
481 detail ??
482 `${context}: Not found (404). Remote Control may not be available for this organization.`,
483 404,
484 errorType,
485 )
486 case 410:
487 throw new BridgeFatalError(
488 detail ??
489 'Remote Control session has expired. Please restart with `claude remote-control` or /remote-control.',
490 410,
491 errorType ?? 'environment_expired',
492 )
493 case 429:
494 throw new Error(`${context}: Rate limited (429). Polling too frequently.`)
495 default:
496 throw new Error(
497 `${context}: Failed with status ${status}${detail ? `: ${detail}` : ''}`,
498 )
499 }
500}
501
502/** Check whether an error type string indicates a session/environment expiry. */
503export function isExpiredErrorType(errorType: string | undefined): boolean {

Callers 9

pollForWorkFunction · 0.85
acknowledgeWorkFunction · 0.85
stopWorkFunction · 0.85
deregisterEnvironmentFunction · 0.85
archiveSessionFunction · 0.85
reconnectSessionFunction · 0.85
heartbeatWorkFunction · 0.85

Calls 3

extractErrorDetailFunction · 0.85
extractErrorTypeFromDataFunction · 0.85
isExpiredErrorTypeFunction · 0.85

Tested by

no test coverage detected