MCPcopy
hub / github.com/QuantumNous/new-api / ResetStatusCode

Function ResetStatusCode

service/error.go:133–156  ·  view source on GitHub ↗
(newApiErr *types.NewAPIError, statusCodeMappingStr string)

Source from the content-addressed store, hash-verified

131}
132
133func ResetStatusCode(newApiErr *types.NewAPIError, statusCodeMappingStr string) {
134 if newApiErr == nil {
135 return
136 }
137 if statusCodeMappingStr == "" || statusCodeMappingStr == "{}" {
138 return
139 }
140 statusCodeMapping := make(map[string]any)
141 err := common.Unmarshal([]byte(statusCodeMappingStr), &statusCodeMapping)
142 if err != nil {
143 return
144 }
145 if newApiErr.StatusCode == http.StatusOK {
146 return
147 }
148 codeStr := strconv.Itoa(newApiErr.StatusCode)
149 if value, ok := statusCodeMapping[codeStr]; ok {
150 intCode, ok := parseStatusCodeMappingValue(value)
151 if !ok {
152 return
153 }
154 newApiErr.StatusCode = intCode
155 }
156}
157
158func parseStatusCodeMappingValue(value any) (int, bool) {
159 switch v := value.(type) {

Callers 13

ClaudeHelperFunction · 0.92
TextHelperFunction · 0.92
GeminiHelperFunction · 0.92
GeminiEmbeddingHandlerFunction · 0.92
EmbeddingHelperFunction · 0.92
ResponsesHelperFunction · 0.92
RerankHelperFunction · 0.92
WssHelperFunction · 0.92
ImageHelperFunction · 0.92
AudioHelperFunction · 0.92
GeminiChatHandlerFunction · 0.92

Calls 2

UnmarshalFunction · 0.92

Tested by 1

TestResetStatusCodeFunction · 0.68