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

Function walkCauses

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

Source from the content-addressed store, hash-verified

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

Callers 2

causeCodeFunction · 0.85
connectionFaultCodeFunction · 0.85

Calls 1

visitFunction · 0.70

Tested by

no test coverage detected