(cause: unknown)
| 1601 | * parent are dropped. |
| 1602 | */ |
| 1603 | const formatUnknownMessage = (cause: unknown): string => { |
| 1604 | const messages: string[] = []; |
| 1605 | const seen = new Set<unknown>(); |
| 1606 | let current: unknown = cause; |
| 1607 | while (current !== null && current !== undefined && !seen.has(current)) { |
| 1608 | seen.add(current); |
| 1609 | const message = ownMessage(current); |
| 1610 | if (message.length > 0 && !messages.some((existing) => existing.includes(message))) { |
| 1611 | messages.push(message); |
| 1612 | } |
| 1613 | current = |
| 1614 | typeof current === "object" && "cause" in current |
| 1615 | ? (current as { cause: unknown }).cause |
| 1616 | : undefined; |
| 1617 | } |
| 1618 | if (messages.length === 0) { |
| 1619 | return typeof cause === "string" |
| 1620 | ? cause |
| 1621 | : cause instanceof Error |
| 1622 | ? cause.message |
| 1623 | : String(cause); |
| 1624 | } |
| 1625 | return messages.join("\ncaused by: "); |
| 1626 | }; |
| 1627 | |
| 1628 | const readCliLogLevel = (argv: ReadonlyArray<string>): string | undefined => { |
| 1629 | for (let index = 0; index < argv.length; index += 1) { |
no test coverage detected