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

Function formatUnknownMessage

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

Source from the content-addressed store, hash-verified

1559 * parent are dropped.
1560 */
1561const formatUnknownMessage = (cause: unknown): string => {
1562 const messages: string[] = [];
1563 const seen = new Set<unknown>();
1564 let current: unknown = cause;
1565 while (current !== null && current !== undefined && !seen.has(current)) {
1566 seen.add(current);
1567 const message = ownMessage(current);
1568 if (message.length > 0 && !messages.some((existing) => existing.includes(message))) {
1569 messages.push(message);
1570 }
1571 current =
1572 typeof current === "object" && "cause" in current
1573 ? (current as { cause: unknown }).cause
1574 : undefined;
1575 }
1576 if (messages.length === 0) {
1577 return typeof cause === "string"
1578 ? cause
1579 : cause instanceof Error
1580 ? cause.message
1581 : String(cause);
1582 }
1583 return messages.join("\ncaused by: ");
1584};
1585
1586const readCliLogLevel = (argv: ReadonlyArray<string>): string | undefined => {
1587 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