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

Function formatUnknownMessage

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

Source from the content-addressed store, hash-verified

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