Merge pull request #77 from unistack-org/feature
test error transfering from grpc server
This commit is contained in:
commit
f6b1c8d745
20
error.go
20
error.go
@ -22,23 +22,19 @@ func microError(err error) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// return first error from details
|
details := s.Details()
|
||||||
if details := s.Details(); len(details) > 0 {
|
switch len(details) {
|
||||||
|
case 0:
|
||||||
|
return err
|
||||||
|
case 1:
|
||||||
if verr, ok := details[0].(error); ok {
|
if verr, ok := details[0].(error); ok {
|
||||||
return microError(verr)
|
return microError(verr)
|
||||||
}
|
}
|
||||||
}
|
return err
|
||||||
|
default:
|
||||||
// try to decode micro *errors.Error
|
|
||||||
if e := errors.Parse(s.Message()); e.Code > 0 {
|
if e := errors.Parse(s.Message()); e.Code > 0 {
|
||||||
return e // actually a micro error
|
return e // actually a micro error
|
||||||
}
|
}
|
||||||
|
return err
|
||||||
// fallback
|
|
||||||
return &errors.Error{
|
|
||||||
ID: "go.micro.client",
|
|
||||||
Code: int32(s.Code()),
|
|
||||||
Detail: s.Message(),
|
|
||||||
Status: s.Code().String(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user