From 6eea500981afd671950e05a3c316ab9fa6ffe347 Mon Sep 17 00:00:00 2001 From: Liuhaai Date: Wed, 8 Jan 2025 13:42:05 -0800 Subject: [PATCH] fix err handling --- src/tools/weatherapi.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/weatherapi.ts b/src/tools/weatherapi.ts index 5214492..62bfe84 100644 --- a/src/tools/weatherapi.ts +++ b/src/tools/weatherapi.ts @@ -41,11 +41,11 @@ export class WeatherTool implements Tool { headers: { 'x-api-key': this.apiKey, }, + signal: AbortSignal.timeout(5000) }); if (!response.ok) { - const errorData = await response.json(); - const errorMessage = errorData?.message || `API request failed with status: ${response.status} ${response.statusText}`; + const errorMessage = `API request failed with status: ${response.status} ${response.statusText}`; return `Weather API Error: ${errorMessage}`; }