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

Function formatUnknownMessage

apps/cli/src/main.ts:1593–1616  ·  view source on GitHub ↗
(cause: unknown)

Source from the content-addressed store, hash-verified

1591 * parent are dropped.
1592 */
1593const formatUnknownMessage = (cause: unknown): string => {
1594 const messages: string[] = [];
1595 const seen = new Set<unknown>();
1596 let current: unknown = cause;
1597 while (current !== null && current !== undefined && !seen.has(current)) {
1598 seen.add(current);
1599 const message = ownMessage(current);
1600 if (message.length > 0 && !messages.some((existing) => existing.includes(message))) {
1601 messages.push(message);
1602 }
1603 current =
1604 typeof current === "object" && "cause" in current
1605 ? (current as { cause: unknown }).cause
1606 : undefined;
1607 }
1608 if (messages.length === 0) {
1609 return typeof cause === "string"
1610 ? cause
1611 : cause instanceof Error
1612 ? cause.message
1613 : String(cause);
1614 }
1615 return messages.join("\ncaused by: ");
1616};
1617
1618const readCliLogLevel = (argv: ReadonlyArray<string>): string | undefined => {
1619 for (let index = 0; index < argv.length; index += 1) {

Callers 1

renderCliErrorFunction · 0.85

Calls 2

ownMessageFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected