MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / walkCauses

Function walkCauses

packages/core/sdk/src/fuma-runtime.ts:126–138  ·  view source on GitHub ↗
(cause: unknown, visit: (err: Record<string, unknown>) => boolean)

Source from the content-addressed store, hash-verified

124
125/** Walk a cause chain, newest first, at most 5 links deep (as `isUniqueViolation` does). */
126const walkCauses = (cause: unknown, visit: (err: Record<string, unknown>) => boolean): boolean => {
127 let current = cause;
128 for (let i = 0; i < 5; i += 1) {
129 const err =
130 current && typeof current === "object" ? (current as Record<string, unknown>) : null;
131 if (!err) return false;
132 if (visit(err)) return true;
133 const innerCause = err["cause"];
134 if (!innerCause || innerCause === current) return false;
135 current = innerCause;
136 }
137 return false;
138};
139
140/** First driver error code in the cause chain, if any. Never the error text. */
141const causeCode = (cause: unknown): string | undefined => {

Callers 2

causeCodeFunction · 0.85
connectionFaultCodeFunction · 0.85

Calls 1

visitFunction · 0.70

Tested by

no test coverage detected