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

Function formatUnknownMessage

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

Source from the content-addressed store, hash-verified

1537 * parent are dropped.
1538 */
1539const formatUnknownMessage = (cause: unknown): string => {
1540 const messages: string[] = [];
1541 const seen = new Set<unknown>();
1542 let current: unknown = cause;
1543 while (current !== null && current !== undefined && !seen.has(current)) {
1544 seen.add(current);
1545 const message = ownMessage(current);
1546 if (message.length > 0 && !messages.some((existing) => existing.includes(message))) {
1547 messages.push(message);
1548 }
1549 current =
1550 typeof current === "object" && "cause" in current
1551 ? (current as { cause: unknown }).cause
1552 : undefined;
1553 }
1554 if (messages.length === 0) {
1555 return typeof cause === "string"
1556 ? cause
1557 : cause instanceof Error
1558 ? cause.message
1559 : String(cause);
1560 }
1561 return messages.join("\ncaused by: ");
1562};
1563
1564const readCliLogLevel = (argv: ReadonlyArray<string>): string | undefined => {
1565 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