status: rename Status to GRPCStatus to avoid name conflicts (#1944)
This commit is contained in:
Родитель
275695638f
Коммит
9d2250f5c8
|
@ -46,7 +46,7 @@ func (se *statusError) Error() string {
|
|||
return fmt.Sprintf("rpc error: code = %s desc = %s", codes.Code(p.GetCode()), p.GetMessage())
|
||||
}
|
||||
|
||||
func (se *statusError) Status() *Status {
|
||||
func (se *statusError) GRPCStatus() *Status {
|
||||
return &Status{s: (*spb.Status)(se)}
|
||||
}
|
||||
|
||||
|
@ -120,14 +120,14 @@ func FromProto(s *spb.Status) *Status {
|
|||
}
|
||||
|
||||
// FromError returns a Status representing err if it was produced from this
|
||||
// package or has a method Status() *Status. Otherwise, ok is false and a
|
||||
// package or has a method `GRPCStatus() *Status`. Otherwise, ok is false and a
|
||||
// Status is returned with codes.Unknown and the original error message.
|
||||
func FromError(err error) (s *Status, ok bool) {
|
||||
if err == nil {
|
||||
return &Status{s: &spb.Status{Code: int32(codes.OK)}}, true
|
||||
}
|
||||
if se, ok := err.(interface{ Status() *Status }); ok {
|
||||
return se.Status(), true
|
||||
if se, ok := err.(interface{ GRPCStatus() *Status }); ok {
|
||||
return se.GRPCStatus(), true
|
||||
}
|
||||
return New(codes.Unknown, err.Error()), false
|
||||
}
|
||||
|
@ -182,8 +182,8 @@ func Code(err error) codes.Code {
|
|||
if err == nil {
|
||||
return codes.OK
|
||||
}
|
||||
if se, ok := err.(interface{ Status() *Status }); ok {
|
||||
return se.Status().Code()
|
||||
if se, ok := err.(interface{ GRPCStatus() *Status }); ok {
|
||||
return se.GRPCStatus().Code()
|
||||
}
|
||||
return codes.Unknown
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ func (c customError) Error() string {
|
|||
return fmt.Sprintf("rpc error: code = %s desc = %s", c.Code, c.Message)
|
||||
}
|
||||
|
||||
func (c customError) Status() *Status {
|
||||
func (c customError) GRPCStatus() *Status {
|
||||
return &Status{
|
||||
s: &spb.Status{
|
||||
Code: int32(c.Code),
|
||||
|
|
Загрузка…
Ссылка в новой задаче