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 e34bff9 commit 73f9342Copy full SHA for 73f9342
1 file changed
packages/ssestream/streaming.go
@@ -6,9 +6,12 @@ import (
6
"bufio"
7
"bytes"
8
"encoding/json"
9
+ "fmt"
10
"io"
11
"net/http"
12
"strings"
13
+
14
+ "github.com/tidwall/gjson"
15
)
16
17
type Decoder interface {
@@ -144,6 +147,11 @@ func (s *Stream[T]) Next() bool {
144
147
}
145
148
146
149
if s.decoder.Event().Type == "" {
150
+ ep := gjson.GetBytes(s.decoder.Event().Data, "error")
151
+ if ep.Exists() {
152
+ s.err = fmt.Errorf("received error while streaming: %s", ep.String())
153
+ return false
154
+ }
155
s.err = json.Unmarshal(s.decoder.Event().Data, &s.cur)
156
if s.err != nil {
157
return false
0 commit comments