Skip to content

Commit

Permalink
fix: 2024-03-30 22:56:38
Browse files Browse the repository at this point in the history
  • Loading branch information
kooksee committed Mar 30, 2024
1 parent 0bce085 commit 7f83b7f
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions errors/errutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,25 +190,6 @@ func ParseError(err error) *errorpb.Error {
return nil
}

var ce *errors.ErrCode
if errors.As(err, &ce) {
if ce.Proto().Message == "" {
ce.Proto().Message = err.Error()
}

return &errorpb.Error{
Code: ce.Proto(),
Trace: &errorpb.ErrTrace{
Service: version.Project(),
Version: version.Version(),
},
Msg: &errorpb.ErrMsg{
Msg: err.Error(),
Detail: fmt.Sprintf("%#v", err),
},
}
}

// grpc error
gs, ok := err.(errors.GRPCStatus)
if ok {
Expand Down Expand Up @@ -242,6 +223,25 @@ func ParseError(err error) *errorpb.Error {
}
}

var ce *errors.ErrCode
if errors.As(err, &ce) {
if ce.Proto().Message == "" {
ce.Proto().Message = err.Error()
}

return &errorpb.Error{
Code: ce.Proto(),
Trace: &errorpb.ErrTrace{
Service: version.Project(),
Version: version.Version(),
},
Msg: &errorpb.ErrMsg{
Msg: err.Error(),
Detail: fmt.Sprintf("%v", err),
},
}
}

return &errorpb.Error{
Code: &errorpb.ErrCode{
Message: err.Error(),
Expand All @@ -255,7 +255,7 @@ func ParseError(err error) *errorpb.Error {
},
Msg: &errorpb.ErrMsg{
Msg: err.Error(),
Detail: fmt.Sprintf("%#v", err),
Detail: fmt.Sprintf("%v", err),
},
}
}

0 comments on commit 7f83b7f

Please sign in to comment.