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

Function walkCauses

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

Source from the content-addressed store, hash-verified

108
109/** Walk a cause chain, newest first, at most 5 links deep (as `isUniqueViolation` does). */
110const walkCauses = (cause: unknown, visit: (err: Record<string, unknown>) => boolean): boolean => {
111 let current = cause;
112 for (let i = 0; i < 5; i += 1) {
113 const err =
114 current && typeof current === "object" ? (current as Record<string, unknown>) : null;
115 if (!err) return false;
116 if (visit(err)) return true;
117 const innerCause = err["cause"];
118 if (!innerCause || innerCause === current) return false;
119 current = innerCause;
120 }
121 return false;
122};
123
124/** First driver error code in the cause chain, if any. Never the error text. */
125const causeCode = (cause: unknown): string | undefined => {

Callers 2

causeCodeFunction · 0.85
connectionFaultCodeFunction · 0.85

Calls 1

visitFunction · 0.70

Tested by

no test coverage detected