mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-03-30 14:30:48 +00:00
fix: keep 500 status for upstream errors, pass details in response body
Upstream errors like 401/429 must not be passed through as HTTP status codes because the frontend routes on status (401 triggers JWT logout). Keep HTTP 500 but include upstream error details in the message.
This commit is contained in:
@@ -97,7 +97,7 @@ func (s *claudeUsageService) FetchUsageWithOptions(ctx context.Context, opts *se
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
msg := fmt.Sprintf("API returned status %d: %s", resp.StatusCode, string(body))
|
||||
return nil, infraerrors.New(resp.StatusCode, "UPSTREAM_ERROR", msg)
|
||||
return nil, infraerrors.New(http.StatusInternalServerError, "UPSTREAM_ERROR", msg)
|
||||
}
|
||||
|
||||
var usageResp service.ClaudeUsageResponse
|
||||
|
||||
Reference in New Issue
Block a user