Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
picker_wrapper: improve handling of context errors
pickerWrapper had logic very similar to status.FromContextError() for transforming Context errors to status errors. This patch removes the duplication by delegating to the status library. Besides removing the code duplication, the status library is arguably more robust because it doesn't rely on ctx.Error() to only ever return two types of errors. I believe this patch and the previous one stand on their own, but, FWIW, they're also motivating by me wanting to experiment in the CockroachDB codebase with using a custom implementation of context.Context whose Err() method can return better errors than the stdlib context.Context. These errors would still wrap context.Canceled. Such an implementation would technically break the documentation of context.Context, which seems to exhaustively list the sentinel error that context.Context can return. Still, as grpc#4977 showed, most code should support wrapped context errors. This patch moves from "most code" to "all code" in gRPC. I haven't checked which of the callsites I've touched use contexts that might be inherited from a gRPC client, as opposed to contexts derived inside gRPC from context.Background (which contexts would not be affected by whatever I do outside of gRPC), but unifying all the context error handling code seems like a good idea to me universally.
- Loading branch information