Skip to content

Commit

Permalink
fix:conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
constwz committed Nov 30, 2023
1 parent ae134ab commit d499a6e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions base/types/gfsperrors/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ func init() {
})
}

func GetGfSpErr(err error) *GfSpError {
if err == nil {
return nil
}
if gfspErr, ok := err.(*GfSpError); ok {
return gfspErr
}
i := strings.Index(err.Error(), "desc = ")
if i == -1 || len(err.Error())-1 < i+6 {
return nil
}
errInfo := err.Error()[i+6:]
var gfspErr GfSpError
unmarshalErr := json.Unmarshal([]byte(errInfo), &gfspErr)
if unmarshalErr == nil && gfspErr.HttpStatusCode != 0 {
return &gfspErr
}
return nil
}

// MakeGfSpError returns an GfSpError from the build-in error interface. It is
// difficult to predefine all errors. For undefined errors, there needs to be a
// way to capture them and return them to the client according to the GfSpError
Expand Down

0 comments on commit d499a6e

Please sign in to comment.