Skip to content

Commit

Permalink
fix err handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Liuhaai committed Jan 8, 2025
1 parent 997d94a commit 6eea500
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tools/weatherapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}

Expand Down

0 comments on commit 6eea500

Please sign in to comment.