Skip to content

Commit 52948a1

Browse files
committed
refactor(file-transfer): drop unused fs error classifier
1 parent 88c9292 commit 52948a1

2 files changed

Lines changed: 1 addition & 38 deletions

File tree

‎extensions/file-transfer/src/shared/errors.test.ts‎

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// File Transfer tests cover errors plugin behavior.
22
import { describe, expect, it } from "vitest";
3-
import { classifyFsError, err, throwFromNodePayload } from "./errors.js";
3+
import { err, throwFromNodePayload } from "./errors.js";
44

55
describe("err", () => {
66
it("returns an error envelope without canonicalPath when omitted", () => {
@@ -18,28 +18,6 @@ describe("err", () => {
1818
});
1919
});
2020

21-
describe("classifyFsError", () => {
22-
it("maps ENOENT to NOT_FOUND", () => {
23-
expect(classifyFsError({ code: "ENOENT" })).toBe("NOT_FOUND");
24-
});
25-
26-
it("maps EACCES and EPERM to PERMISSION_DENIED", () => {
27-
expect(classifyFsError({ code: "EACCES" })).toBe("PERMISSION_DENIED");
28-
expect(classifyFsError({ code: "EPERM" })).toBe("PERMISSION_DENIED");
29-
});
30-
31-
it("maps EISDIR to IS_DIRECTORY", () => {
32-
expect(classifyFsError({ code: "EISDIR" })).toBe("IS_DIRECTORY");
33-
});
34-
35-
it("falls back to READ_ERROR for unknown / null / non-object input", () => {
36-
expect(classifyFsError({ code: "EUNKNOWN" })).toBe("READ_ERROR");
37-
expect(classifyFsError(null)).toBe("READ_ERROR");
38-
expect(classifyFsError(undefined)).toBe("READ_ERROR");
39-
expect(classifyFsError("nope")).toBe("READ_ERROR");
40-
});
41-
});
42-
4321
describe("throwFromNodePayload", () => {
4422
it("preserves code and message in the thrown Error", () => {
4523
expect(() =>

‎extensions/file-transfer/src/shared/errors.ts‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,6 @@ export function err(
4242
return { ok: false, code, message, ...(canonicalPath ? { canonicalPath } : {}) };
4343
}
4444

45-
// Translate a node-side fs error to a public error code.
46-
export function classifyFsError(e: unknown): FileTransferErrCode {
47-
const code = (e as { code?: string } | null)?.code;
48-
if (code === "ENOENT") {
49-
return "NOT_FOUND";
50-
}
51-
if (code === "EACCES" || code === "EPERM") {
52-
return "PERMISSION_DENIED";
53-
}
54-
if (code === "EISDIR") {
55-
return "IS_DIRECTORY";
56-
}
57-
return "READ_ERROR";
58-
}
59-
6045
// Convert a node-host error payload to a thrown Error for agent-tool consumption.
6146
// The agent-tool surfaces these as failed tool results uniformly.
6247
export function throwFromNodePayload(operation: string, payload: Record<string, unknown>): never {

0 commit comments

Comments
 (0)