(cause: unknown)
| 1537 | * parent are dropped. |
| 1538 | */ |
| 1539 | const 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 | |
| 1564 | const readCliLogLevel = (argv: ReadonlyArray<string>): string | undefined => { |
| 1565 | for (let index = 0; index < argv.length; index += 1) { |
no test coverage detected