File size: 669 Bytes
e18726e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const AGENT_RUN_STALE_LIFECYCLE_ERROR = "Agent run belongs to a stale gateway lifecycle";
const AGENT_RUN_STALE_LIFECYCLE_ERROR_CODE = "ERR_STALE_GATEWAY_LIFECYCLE";

export function createAgentRunStaleLifecycleError(): Error {
  const error = new Error(AGENT_RUN_STALE_LIFECYCLE_ERROR) as Error & { code: string };
  error.name = "AbortError";
  error.code = AGENT_RUN_STALE_LIFECYCLE_ERROR_CODE;
  return error;
}

export function isAgentRunStaleLifecycleError(value: unknown): boolean {
  try {
    return (
      value instanceof Error &&
      "code" in value &&
      value.code === AGENT_RUN_STALE_LIFECYCLE_ERROR_CODE
    );
  } catch {
    return false;
  }
}