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

Function NewError

types/error.go:244–264  ·  view source on GitHub ↗
(err error, errorCode ErrorCode, ops ...NewAPIErrorOptions)

Source from the content-addressed store, hash-verified

242type NewAPIErrorOptions func(*NewAPIError)
243
244func NewError(err error, errorCode ErrorCode, ops ...NewAPIErrorOptions) *NewAPIError {
245 var newErr *NewAPIError
246 // 保留深层传递的 new err
247 if errors.As(err, &newErr) {
248 for _, op := range ops {
249 op(newErr)
250 }
251 return newErr
252 }
253 e := &NewAPIError{
254 Err: err,
255 RelayError: nil,
256 errorType: ErrorTypeNewAPIError,
257 StatusCode: http.StatusInternalServerError,
258 errorCode: errorCode,
259 }
260 for _, op := range ops {
261 op(e)
262 }
263 return e
264}
265
266func NewOpenAIError(err error, errorCode ErrorCode, statusCode int, ops ...NewAPIErrorOptions) *NewAPIError {
267 var newErr *NewAPIError

Callers 15

testChannelFunction · 0.92
PlaygroundFunction · 0.92
RelayFunction · 0.92
getChannelFunction · 0.92
PreConsumeQuotaFunction · 0.92
preConsumeMethod · 0.92
reserveFundingMethod · 0.92
NewBillingSessionFunction · 0.92
GetNextEnabledKeyMethod · 0.92
ClaudeHelperFunction · 0.92
TextHelperFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected