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

Function formatUnknownMessage

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

Source from the content-addressed store, hash-verified

1580 * parent are dropped.
1581 */
1582const formatUnknownMessage = (cause: unknown): string => {
1583 const messages: string[] = [];
1584 const seen = new Set<unknown>();
1585 let current: unknown = cause;
1586 while (current !== null && current !== undefined && !seen.has(current)) {
1587 seen.add(current);
1588 const message = ownMessage(current);
1589 if (message.length > 0 && !messages.some((existing) => existing.includes(message))) {
1590 messages.push(message);
1591 }
1592 current =
1593 typeof current === "object" && "cause" in current
1594 ? (current as { cause: unknown }).cause
1595 : undefined;
1596 }
1597 if (messages.length === 0) {
1598 return typeof cause === "string"
1599 ? cause
1600 : cause instanceof Error
1601 ? cause.message
1602 : String(cause);
1603 }
1604 return messages.join("\ncaused by: ");
1605};
1606
1607const readCliLogLevel = (argv: ReadonlyArray<string>): string | undefined => {
1608 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