Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix err handling #17

Merged
merged 1 commit into from
Jan 8, 2025
Merged
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
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();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug

Error fetching weather data: 45 |             });
46 |
47 |             console.log("response", response);
48 |
49 |             if (!response.ok) {
50 |                 const errorData = await response.json();
                                                      ^
SyntaxError: Failed to parse JSON
      at /quicksilver/src/tools/weatherapi.ts:50:50

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
Loading