carousell/Orion

Assign default gRPC status in the first place when the error generated

changchingchen opened this issue · 0 comments

For current implementation of function WrapWithSkipAndStatus, if the status is not provided for the first time when the error generated, the status will still remain nil without default value. The default status will be given in the following two situations:

  1. One has generated the error using Orion/utils/errors and then wrap it again. In this case, since the error is originally generated by Orion/utils/errors, the interface interface { GRPCStatus() *Stauts} is then implemented. Thus, the default status will be assigned to a status with gRPC code equals to codes.Internal in the implemented GRPCStatus() *Status function when one wrapping the error again.
  2. One has generated the error using Orion/utils/errors and this error is passed to another gRPC endpoints. In this case, the reason is the same as above situation. When error is passed to another gRPC endpoint, the implemented GRPCStatus() *Status function will be called. Thus, it will then generate a default status with gRPC code equals to codes.Internal.

If the default value of the status will be given in the end, then it should be given in the first place when the error is generated rather than when the error is wrapped again or passed to different gRPC endpoints.

Ref: #106