The best way to control Claude Code, Codex and more from any computer or phone

main
ts 22 lines 898 Bytes
Raw
1 import * as NodeOS from "node:os";
2 import { assert, it } from "vite-plus/test";
3
4 import { handleStdioError } from "./stdioErrors.ts";
5
6 const errorWithCode = (code: string, errno?: number) =>
7 Object.assign(new Error(code), { code, errno });
8 const EDQUOT_ERRNO = NodeOS.constants.errno.EDQUOT;
9
10 it.each(["EPIPE", "ENOSPC"])("ignores %s on console output", (code) => {
11 assert.doesNotThrow(() => handleStdioError(errorWithCode(code)));
12 });
13
14 // Node reports EDQUOT as UNKNOWN because libuv has no name for it.
15 it.skipIf(EDQUOT_ERRNO === undefined)("ignores EDQUOT on console output", () => {
16 assert.doesNotThrow(() => handleStdioError(errorWithCode("UNKNOWN", -(EDQUOT_ERRNO ?? 0))));
17 });
18
19 it("rethrows other console output errors", () => {
20 assert.throws(() => handleStdioError(errorWithCode("EIO")), "EIO");
21 assert.throws(() => handleStdioError(errorWithCode("UNKNOWN", -5)), "UNKNOWN");
22 });