Conversation
|
There was a problem hiding this comment.
Pull Request Overview
This PR updates the SDK version to 0.0.5 and improves error handling in the API client by extracting response text from failed HTTP requests before rejecting the promise.
- Modified error handling to read and return response text instead of the raw response object
- Bumped package version from 0.0.4 to 0.0.5
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/api-client.ts | Enhanced error handling to extract and return response text for failed requests |
| package.json | Incremented version number to 0.0.5 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
The response object is being returned on API errors instead of a human readable error message.
This means the calling code has to call
await error.text()in the surrounding catch block, which is an anti-pattern since other functions in the try block could throw a different type.If you call
you get something like
Error: [Response object].With this change, this log code in the catch block now gives something readable like the following without having to assume the error object is a response object at runtime
{"statusCode":400,"timestamp":"2025-11-06T02:17:35.478Z","path":"/v1/actions/enter","message":"Value must be at least 0.1"}