(
error: unknown,
options: StartupErrorFormatOptions = {},
)
| 13 | } |
| 14 | |
| 15 | export function formatStartupError( |
| 16 | error: unknown, |
| 17 | options: StartupErrorFormatOptions = {}, |
| 18 | ): string { |
| 19 | const errorStyle = options.errorStyle ?? chalkStderr.hex(STARTUP_ERROR_COLOR); |
| 20 | |
| 21 | if (!isKimiError(error)) { |
| 22 | const operation = options.operation ?? 'start shell'; |
| 23 | return `${errorStyle(`error: failed to ${operation}: ${formatUnknownErrorMessage(error)}`)}\n`; |
| 24 | } |
| 25 | |
| 26 | const info = KIMI_ERROR_INFO[error.code]; |
| 27 | const lines = [ |
| 28 | errorStyle(`error: ${info.title}`), |
| 29 | '', |
| 30 | errorStyle('message:'), |
| 31 | errorStyle(error.message), |
| 32 | ]; |
| 33 | |
| 34 | return `${lines.join('\n')}\n`; |
| 35 | } |
no test coverage detected