Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/footprinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
)
}

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/fp-string-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
)
})
6 changes: 6 additions & 0 deletions tests/string-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
)
})
4 changes: 3 additions & 1 deletion tests/vssop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"',
)
}
})

Expand Down