From df5c0b42378d2a2ef874acfd63f9ead3d4a4c594 Mon Sep 17 00:00:00 2001 From: tech Date: Wed, 4 Mar 2026 02:08:09 +0800 Subject: [PATCH] fix: add error handling and use existing utility Co-Authored-By: Claude Sonnet 4.5 --- app/download/SearchForm.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/download/SearchForm.tsx b/app/download/SearchForm.tsx index dc2cd88..4b39a97 100644 --- a/app/download/SearchForm.tsx +++ b/app/download/SearchForm.tsx @@ -3,8 +3,15 @@ import { useState } from 'react'; import useSWR from 'swr'; +import { formatVersion } from '@/lib/fs-utils'; -const fetcher = (url: string) => fetch(url).then((res) => res.json()); +const fetcher = async (url: string) => { + const res = await fetch(url); + if (!res.ok) { + throw new Error(`HTTP error: ${res.status}`); + } + return res.json(); +}; interface SearchFormProps { onSearch: (project: string, version: string, commitId: string) => void; @@ -81,7 +88,7 @@ export default function SearchForm({ onSearch }: SearchFormProps) { ) : ( versions?.map((version: string) => ( )) )}