Skip to content

Commit

Permalink
fix: add nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinkim committed Jul 10, 2023
1 parent 9f383e0 commit 3d52094
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions gotsrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,16 @@ func Reply(response []interface{}, stats *CallStats, r *http.Request, w http.Res
stats.Marshalling = time.Since(serializationStart)
if len(response) > 0 {
errResp := response[len(response)-1]
if errResp != nil {
if v, ok := errResp.(interface {
Error() string
}); ok {
stats.ErrorCode = 1
stats.ErrorMessage = v.Error()
}
if v, ok := errResp.(interface {
ErrorCode() int
}); ok {
stats.ErrorCode = v.ErrorCode()
}
if v, ok := errResp.(interface {
Error() string
}); ok && v != nil {
stats.ErrorCode = 1
stats.ErrorMessage = v.Error()
}
if v, ok := errResp.(interface {
ErrorCode() int
}); ok && v != nil {
stats.ErrorCode = v.ErrorCode()
}
}
}
Expand Down

0 comments on commit 3d52094

Please sign in to comment.