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

Function NewErrorWithStatusCode

types/error.go:299–315  ·  view source on GitHub ↗
(err error, errorCode ErrorCode, statusCode int, ops ...NewAPIErrorOptions)

Source from the content-addressed store, hash-verified

297}
298
299func NewErrorWithStatusCode(err error, errorCode ErrorCode, statusCode int, ops ...NewAPIErrorOptions) *NewAPIError {
300 e := &NewAPIError{
301 Err: err,
302 RelayError: OpenAIError{
303 Message: err.Error(),
304 Type: string(errorCode),
305 },
306 errorType: ErrorTypeNewAPIError,
307 StatusCode: statusCode,
308 errorCode: errorCode,
309 }
310 for _, op := range ops {
311 op(e)
312 }
313
314 return e
315}
316
317func WithOpenAIError(openAIError OpenAIError, statusCode int, ops ...NewAPIErrorOptions) *NewAPIError {
318 code, ok := openAIError.Code.(string)

Callers 15

checkSystemPerformanceFunction · 0.92
RelayFunction · 0.92
PreConsumeQuotaFunction · 0.92
preConsumeMethod · 0.92
reserveFundingMethod · 0.92
reserveTokenMethod · 0.92
NewBillingSessionFunction · 0.92
ClaudeHelperFunction · 0.92
TextHelperFunction · 0.92
GeminiHelperFunction · 0.92
EmbeddingHelperFunction · 0.92
ResponsesHelperFunction · 0.92

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected