Skip to content

Commit 8d3a30b

Browse files
author
Gaël Philippe
committed
fix(errors): some errors are not being reported
1 parent 91507b2 commit 8d3a30b

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Sources/OpenAI/Private/Streaming/StreamingSession.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,17 @@ final class StreamingSession<Interpreter: StreamInterpreter>: NSObject, Identifi
8484
if let contentLengthRaw = httpResponse.value(forHTTPHeaderField: "content-length"),
8585
let contentLength = Int(contentLengthRaw)
8686
{
87+
if contentLength > 0, let contentType = httpResponse.value(forHTTPHeaderField: "content-type") {,
88+
contentType.starts(with: "text/plain;") {
89+
let error = OpenAIError.statusError(
90+
response: httpResponse,
91+
statusCode: httpResponse.statusCode
92+
)
93+
self.onProcessingError?(self, error)
94+
return
95+
} else {
8796
completionHandler(.allow)
97+
}
8898
} else if let contentType = httpResponse.value(forHTTPHeaderField: "content-type") {
8999
completionHandler(.allow)
90100
} else {

0 commit comments

Comments
 (0)