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

Function parseStatusCodeMappingValue

service/error.go:158–185  ·  view source on GitHub ↗
(value any)

Source from the content-addressed store, hash-verified

156}
157
158func parseStatusCodeMappingValue(value any) (int, bool) {
159 switch v := value.(type) {
160 case string:
161 if v == "" {
162 return 0, false
163 }
164 statusCode, err := strconv.Atoi(v)
165 if err != nil {
166 return 0, false
167 }
168 return statusCode, true
169 case float64:
170 if v != math.Trunc(v) {
171 return 0, false
172 }
173 return int(v), true
174 case int:
175 return v, true
176 case json.Number:
177 statusCode, err := strconv.Atoi(v.String())
178 if err != nil {
179 return 0, false
180 }
181 return statusCode, true
182 default:
183 return 0, false
184 }
185}
186
187func TaskErrorWrapperLocal(err error, code string, statusCode int) *dto.TaskError {
188 openaiErr := TaskErrorWrapper(err, code, statusCode)

Callers 1

ResetStatusCodeFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected