Skip to content

Commit

Permalink
error details from response
Browse files Browse the repository at this point in the history
  • Loading branch information
karamba228 committed Feb 7, 2025
1 parent 37e704d commit 806d0fc
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/utils/score_res.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,12 @@ export async function fetchPackageScore(
ecosystem: string,
name: string,
): Promise<PackageScore> {
if (!(ecosystem in ({} as EcosystemDestination))) {
throw new Error(`Invalid ecosystem: "${ecosystem}".`);
}
const url = `${BASE_URL}/score/${ecosystem.toLowerCase()}/${name}`;
console.debug(url);
const res = await fetch(url);
if (res.status != 200) {
throw new Error("Failed to fetch package score");
const error = await res.json();
throw error.detail;
}
const data = await res.json();
return data;
Expand Down

0 comments on commit 806d0fc

Please sign in to comment.