diff --git a/lib/websafe/fetch-easyeda-json.ts b/lib/websafe/fetch-easyeda-json.ts index 3ccfb791..945fdd02 100644 --- a/lib/websafe/fetch-easyeda-json.ts +++ b/lib/websafe/fetch-easyeda-json.ts @@ -107,12 +107,12 @@ export async function fetchEasyEDAComponent( }) if (!searchResponse.ok) { - throw new Error("Failed to search for the component") + throw new Error(`Failed to search for component ${jlcpcbPartNumber} from EasyEDA API`) } const searchResult = await searchResponse.json() if (!searchResult.success || !searchResult.result.lists.lcsc.length) { - throw new Error("Component not found") + throw new Error(`Component with JLCPCB part number ${jlcpcbPartNumber} not found in EasyEDA database. This part may exist on JLCPCB but lacks EasyEDA footprint data.`) } const bestMatchComponent = @@ -133,7 +133,7 @@ export async function fetchEasyEDAComponent( }) if (!componentResponse.ok) { - throw new Error("Failed to fetch the component details") + throw new Error(`Failed to fetch component details for ${jlcpcbPartNumber} from EasyEDA API`) } const componentResult = await componentResponse.json() diff --git a/tests/fetch-tests/c9900037709.test.ts b/tests/fetch-tests/c9900037709.test.ts new file mode 100644 index 00000000..f9e04eab --- /dev/null +++ b/tests/fetch-tests/c9900037709.test.ts @@ -0,0 +1,8 @@ +import { it, expect } from "bun:test" +import { fetchEasyEDAComponent } from "lib/websafe/fetch-easyeda-json" + +it("should throw descriptive error for C9900037709 (not in EasyEDA database)", async () => { + await expect(fetchEasyEDAComponent("C9900037709")).rejects.toThrow( + "Component with JLCPCB part number C9900037709 not found in EasyEDA database", + ) +})