Skip to content

fix: wrong error code sometimes #847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions open_im_sdk/caller.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ func call(callback open_im_sdk_callback.Base, operationID string, fn any, args .
go func() {
res, err := call_(operationID, fn, args...)
if err != nil {
if code, ok := err.(errs.CodeError); ok {
callback.OnError(int32(code.Code()), code.Error())
if code, ok := errs.Unwrap(err).(errs.CodeError); ok {
callback.OnError(int32(code.Code()), err.Error())
} else {
callback.OnError(sdkerrs.UnknownCode, fmt.Sprintf("error %T not implement CodeError: %s", err, err))
}
Expand Down Expand Up @@ -445,8 +445,8 @@ func messageCall_(callback open_im_sdk_callback.SendMsgCallBack, operationID str
}
if lastErr {
if last := outVals[len(outVals)-1]; last != nil {
if code, ok := last.(error).(errs.CodeError); ok {
callback.OnError(int32(code.Code()), code.Error())
if code, ok := errs.Unwrap(last.(error)).(errs.CodeError); ok {
callback.OnError(int32(code.Code()), last.(error).Error())
} else {
callback.OnError(sdkerrs.UnknownCode, fmt.Sprintf("error %T not implement CodeError: %s", last.(error), last.(error).Error()))
}
Expand Down
Loading