mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-19 04:40:52 +08:00
fix(amp): set status on claude stream errors
This commit is contained in:
@@ -271,6 +271,11 @@ func (h *ClaudeCodeAPIHandler) forwardClaudeStream(c *gin.Context, flusher http.
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if errMsg != nil {
|
if errMsg != nil {
|
||||||
|
status := http.StatusInternalServerError
|
||||||
|
if errMsg.StatusCode > 0 {
|
||||||
|
status = errMsg.StatusCode
|
||||||
|
}
|
||||||
|
c.Status(status)
|
||||||
// An error occurred: emit as a proper SSE error event
|
// An error occurred: emit as a proper SSE error event
|
||||||
errorBytes, _ := json.Marshal(h.toClaudeError(errMsg))
|
errorBytes, _ := json.Marshal(h.toClaudeError(errMsg))
|
||||||
_, _ = writer.WriteString("event: error\n")
|
_, _ = writer.WriteString("event: error\n")
|
||||||
@@ -278,6 +283,7 @@ func (h *ClaudeCodeAPIHandler) forwardClaudeStream(c *gin.Context, flusher http.
|
|||||||
_, _ = writer.Write(errorBytes)
|
_, _ = writer.Write(errorBytes)
|
||||||
_, _ = writer.WriteString("\n\n")
|
_, _ = writer.WriteString("\n\n")
|
||||||
_ = writer.Flush()
|
_ = writer.Flush()
|
||||||
|
flusher.Flush()
|
||||||
}
|
}
|
||||||
var execErr error
|
var execErr error
|
||||||
if errMsg != nil {
|
if errMsg != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user