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.
2 parents a7fcc26 + 4a79315 commit f03d3cbCopy full SHA for f03d3cb
1 file changed
src/streaming.ts
@@ -88,7 +88,26 @@ export class Stream<Item> implements AsyncIterable<Item> {
88
}
89
90
if (sse.event === 'error') {
91
- throw APIError;
+ let errorData: any;
92
+ try {
93
+ errorData = JSON.parse(sse.data);
94
+ } catch (e) {
95
+ console.error('Could not parse message into JSON:', sse.data);
96
+ console.error('From chunk:', sse.raw);
97
+ throw new APIError(
98
+ undefined,
99
100
+ 'Unknown error',
101
+ undefined
102
+ );
103
+ }
104
+
105
106
107
+ errorData,
108
+ errorData.message,
109
110
111
112
113
} catch (e) {
0 commit comments