We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bcd3919 commit 232f240Copy full SHA for 232f240
src/BaseApi.ts
@@ -52,11 +52,20 @@ export class BaseApi {
52
};
53
54
if (response.status < 200 || response.status >= 300) {
55
- const error = (await response.json()) as APIError;
+ let error: APIError;
56
+ try {
57
+ error = (await response.json()) as APIError;
58
+ } catch (_) {
59
+ throw new StreamError(
60
+ `Stream error: ${response.status} - ${response.statusText}`,
61
+ metadata,
62
+ response.status,
63
+ );
64
+ }
65
throw new StreamError(
- `Stream error code ${error.code}: ${error.message}`,
66
+ `Stream error code ${error!.code}: ${error!.message}`,
67
metadata,
- error.code,
68
+ error!.code,
69
undefined,
70
);
71
}
0 commit comments