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
e3d97e4d
authored
Jul 22, 2025
by
feitianbubu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: avoid relayError nil panic
parent
38002f20
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
types/error.go
+21
-16
No files found.
types/error.go
View file @
e3d97e4d
...
...
@@ -105,23 +105,25 @@ func (e *NewAPIError) SetMessage(message string) {
func
(
e
*
NewAPIError
)
ToOpenAIError
()
OpenAIError
{
switch
e
.
ErrorType
{
case
ErrorTypeOpenAIError
:
return
e
.
RelayError
.
(
OpenAIError
)
case
ErrorTypeClaudeError
:
claudeError
:=
e
.
RelayError
.
(
ClaudeError
)
return
OpenAIError
{
Message
:
e
.
Error
(),
Type
:
claudeError
.
Type
,
Param
:
""
,
Code
:
e
.
errorCode
,
if
openAIError
,
ok
:=
e
.
RelayError
.
(
OpenAIError
);
ok
{
return
openAIError
}
default
:
return
OpenAIError
{
Message
:
e
.
Error
(),
Type
:
string
(
e
.
ErrorType
),
Param
:
""
,
Code
:
e
.
errorCode
,
case
ErrorTypeClaudeError
:
if
claudeError
,
ok
:=
e
.
RelayError
.
(
ClaudeError
);
ok
{
return
OpenAIError
{
Message
:
e
.
Error
(),
Type
:
claudeError
.
Type
,
Param
:
""
,
Code
:
e
.
errorCode
,
}
}
}
return
OpenAIError
{
Message
:
e
.
Error
(),
Type
:
string
(
e
.
ErrorType
),
Param
:
""
,
Code
:
e
.
errorCode
,
}
}
func
(
e
*
NewAPIError
)
ToClaudeError
()
ClaudeError
{
...
...
@@ -162,8 +164,11 @@ func NewOpenAIError(err error, errorCode ErrorCode, statusCode int) *NewAPIError
func
NewErrorWithStatusCode
(
err
error
,
errorCode
ErrorCode
,
statusCode
int
)
*
NewAPIError
{
return
&
NewAPIError
{
Err
:
err
,
RelayError
:
nil
,
Err
:
err
,
RelayError
:
OpenAIError
{
Message
:
err
.
Error
(),
Type
:
string
(
errorCode
),
},
ErrorType
:
ErrorTypeNewAPIError
,
StatusCode
:
statusCode
,
errorCode
:
errorCode
,
...
...
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