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
b85106b5
authored
Jul 19, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: create NewOpenAIError function for improved error handling in Relay
parent
386c2546
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletions
+9
-1
relay/relay-text.go
+1
-1
types/error.go
+8
-0
No files found.
relay/relay-text.go
View file @
b85106b5
...
@@ -210,7 +210,7 @@ func TextHelper(c *gin.Context) (newAPIError *types.NewAPIError) {
...
@@ -210,7 +210,7 @@ func TextHelper(c *gin.Context) (newAPIError *types.NewAPIError) {
resp
,
err
:=
adaptor
.
DoRequest
(
c
,
relayInfo
,
requestBody
)
resp
,
err
:=
adaptor
.
DoRequest
(
c
,
relayInfo
,
requestBody
)
if
err
!=
nil
{
if
err
!=
nil
{
return
types
.
New
Error
(
err
,
types
.
ErrorCodeDoRequestFailed
)
return
types
.
New
OpenAIError
(
err
,
types
.
ErrorCodeDoRequestFailed
,
http
.
StatusInternalServerError
)
}
}
statusCodeMappingStr
:=
c
.
GetString
(
"status_code_mapping"
)
statusCodeMappingStr
:=
c
.
GetString
(
"status_code_mapping"
)
...
...
types/error.go
View file @
b85106b5
...
@@ -152,6 +152,14 @@ func NewError(err error, errorCode ErrorCode) *NewAPIError {
...
@@ -152,6 +152,14 @@ func NewError(err error, errorCode ErrorCode) *NewAPIError {
}
}
}
}
func
NewOpenAIError
(
err
error
,
errorCode
ErrorCode
,
statusCode
int
)
*
NewAPIError
{
openaiError
:=
OpenAIError
{
Message
:
err
.
Error
(),
Type
:
string
(
errorCode
),
}
return
WithOpenAIError
(
openaiError
,
statusCode
)
}
func
NewErrorWithStatusCode
(
err
error
,
errorCode
ErrorCode
,
statusCode
int
)
*
NewAPIError
{
func
NewErrorWithStatusCode
(
err
error
,
errorCode
ErrorCode
,
statusCode
int
)
*
NewAPIError
{
return
&
NewAPIError
{
return
&
NewAPIError
{
Err
:
err
,
Err
:
err
,
...
...
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