MCPcopy
hub / github.com/zgsm-ai/costrict / isExpectedControlFlowError

Function isExpectedControlFlowError

apps/cli/src/commands/cli/cancellation.ts:106–131  ·  view source on GitHub ↗
(error: unknown, context: ExpectedControlFlowErrorContext)

Source from the content-addressed store, hash-verified

104 * fatal failures while handling stdin stream tasks.
105 */
106export function isExpectedControlFlowError(error: unknown, context: ExpectedControlFlowErrorContext): boolean {
107 if (!context.stdinStreamMode) {
108 return false
109 }
110
111 if (context.shuttingDown && isStreamTeardownLikeError(error)) {
112 return true
113 }
114
115 const isCancelLike = isCancellationLikeError(error)
116 if (isCancelLike && (context.cancelRequested || context.shuttingDown || context.operation === "runtime")) {
117 return true
118 }
119
120 if (
121 isNoActiveTaskLikeError(error) &&
122 (context.cancelRequested ||
123 context.shuttingDown ||
124 context.operation === "cancel" ||
125 context.operation === "shutdown")
126 ) {
127 return true
128 }
129
130 return false
131}

Callers 4

onUncaughtExceptionFunction · 0.85
onUnhandledRejectionFunction · 0.85
runStdinStreamModeFunction · 0.85

Calls 3

isCancellationLikeErrorFunction · 0.85
isNoActiveTaskLikeErrorFunction · 0.85

Tested by

no test coverage detected