(error: unknown)
| 10 | |
| 11 | /** Format CLI and startup failures without exposing Bun internal stack frames for expected errors. */ |
| 12 | export function formatCliError(error: unknown) { |
| 13 | if (error instanceof HunkUserError) { |
| 14 | const lines = [`hunk: ${error.message}`]; |
| 15 | |
| 16 | if (error.details.length > 0) { |
| 17 | lines.push("", ...error.details); |
| 18 | } |
| 19 | |
| 20 | return `${lines.join("\n")}\n`; |
| 21 | } |
| 22 | |
| 23 | if (error instanceof Error) { |
| 24 | if (process.env.HUNK_DEBUG === "1" && error.stack) { |
| 25 | return `${error.stack}\n`; |
| 26 | } |
| 27 | |
| 28 | return `hunk: ${error.message}\n`; |
| 29 | } |
| 30 | |
| 31 | return `hunk: ${String(error)}\n`; |
| 32 | } |
no outgoing calls
no test coverage detected