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
6 changes: 3 additions & 3 deletions lib/websafe/fetch-easyeda-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions tests/fetch-tests/c9900037709.test.ts
Original file line number Diff line number Diff line change
@@ -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",
)
})