Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3243f229
authored
Jul 25, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add upstream error type and default handling for OpenAI and Claude errors
parent
0e2ec053
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
types/error.go
+7
-0
No files found.
types/error.go
View file @
3243f229
...
...
@@ -28,6 +28,7 @@ const (
ErrorTypeMidjourneyError
ErrorType
=
"midjourney_error"
ErrorTypeGeminiError
ErrorType
=
"gemini_error"
ErrorTypeRerankError
ErrorType
=
"rerank_error"
ErrorTypeUpstreamError
ErrorType
=
"upstream_error"
)
type
ErrorCode
string
...
...
@@ -194,6 +195,9 @@ func WithOpenAIError(openAIError OpenAIError, statusCode int) *NewAPIError {
if
!
ok
{
code
=
fmt
.
Sprintf
(
"%v"
,
openAIError
.
Code
)
}
if
openAIError
.
Type
==
""
{
openAIError
.
Type
=
"upstream_error"
}
return
&
NewAPIError
{
RelayError
:
openAIError
,
errorType
:
ErrorTypeOpenAIError
,
...
...
@@ -204,6 +208,9 @@ func WithOpenAIError(openAIError OpenAIError, statusCode int) *NewAPIError {
}
func
WithClaudeError
(
claudeError
ClaudeError
,
statusCode
int
)
*
NewAPIError
{
if
claudeError
.
Type
==
""
{
claudeError
.
Type
=
"upstream_error"
}
return
&
NewAPIError
{
RelayError
:
claudeError
,
errorType
:
ErrorTypeClaudeError
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment