* Classify an error from the Coder CLI as missing or error with message.
(error: unknown)
| 472 | * Classify an error from the Coder CLI as missing or error with message. |
| 473 | */ |
| 474 | private classifyCoderError(error: unknown): CoderInfo { |
| 475 | // ENOENT or "command not found" = CLI not installed |
| 476 | if (error instanceof Error) { |
| 477 | const code = (error as NodeJS.ErrnoException).code; |
| 478 | const message = error.message.toLowerCase(); |
| 479 | if ( |
| 480 | code === "ENOENT" || |
| 481 | message.includes("command not found") || |
| 482 | message.includes("enoent") |
| 483 | ) { |
| 484 | return { state: "unavailable", reason: "missing" }; |
| 485 | } |
| 486 | // Other errors: include sanitized message (single line, capped length) |
| 487 | const sanitized = sanitizeCoderCliErrorForUi(error); |
| 488 | return { |
| 489 | state: "unavailable", |
| 490 | reason: { kind: "error", message: sanitized }, |
| 491 | }; |
| 492 | } |
| 493 | return { state: "unavailable", reason: { kind: "error", message: "Unknown error" } }; |
| 494 | } |
| 495 | |
| 496 | /** |
| 497 | * Create a short-lived Coder API token for deployment endpoints. |
no test coverage detected