diff --git a/src/footprinter.ts b/src/footprinter.ts index fa51a3b4..ce36b81f 100644 --- a/src/footprinter.ts +++ b/src/footprinter.ts @@ -364,9 +364,7 @@ export const footprinter = (): Footprinter & { if (!FOOTPRINT_FN[target.fn]) { throw new Error( - `Invalid footprint function, got "${target.fn}"${ - target.string ? `, from string "${target.string}"` : "" - }`, + `Function not found for footprinter "${target.fn}". Specify a valid function like .dip, .lr, .p etc.`, ) } @@ -380,9 +378,7 @@ export const footprinter = (): Footprinter & { if (prop === "json") { if (!FOOTPRINT_FN[target.fn]) { throw new Error( - `Invalid footprint function, got "${target.fn}"${ - target.string ? `, from string "${target.string}"` : "" - }`, + `Function not found for footprinter "${target.fn}". Specify a valid function like .dip, .lr, .p etc.`, ) } return () => FOOTPRINT_FN[target.fn](target).parameters diff --git a/tests/fp-string-error.test.ts b/tests/fp-string-error.test.ts index 1e6c4227..bd0789d4 100644 --- a/tests/fp-string-error.test.ts +++ b/tests/fp-string-error.test.ts @@ -3,6 +3,6 @@ import { fp } from "src/footprinter" test("fp.string error", () => { expect(() => fp.string("nonexistentfn4_p3").circuitJson()).toThrow( - 'Invalid footprint function, got "nonexistentfn", from string "nonexistentfn4_p3"', + 'Function not found for footprinter "nonexistentfn". Specify a valid function like .dip, .lr, .p etc.', ) }) diff --git a/tests/string-parser.test.ts b/tests/string-parser.test.ts index 7ee639dc..ecdb8ceb 100644 --- a/tests/string-parser.test.ts +++ b/tests/string-parser.test.ts @@ -4,3 +4,9 @@ import { fp } from "../src/footprinter" test("string builder ignores empty segments", () => { expect(() => fp.string("0603__").circuitJson()).not.toThrow() }) + +test("invalid footprint function error identifies the missing function", () => { + expect(() => fp.string("invalid").circuitJson()).toThrow( + 'Function not found for footprinter "invalid". Specify a valid function like .dip, .lr, .p etc.', + ) +}) diff --git a/tests/vssop.test.ts b/tests/vssop.test.ts index 0b12cc27..ce85294b 100644 --- a/tests/vssop.test.ts +++ b/tests/vssop.test.ts @@ -123,7 +123,9 @@ test("invalid_vssop6", () => { } catch (error) { const e = error as Error expect(e).toBeInstanceOf(Error) - expect(e.message).toContain("Invalid footprint function") + expect(e.message).toContain( + 'Function not found for footprinter "invalid"', + ) } })