core/internal/api: use gRPC statuses as much as possible
Returning plain go errors via gRPC will always result in a gRPC 'INTERNAL' error code, which is suboptimal. We go ahead and semanticize some of the possible error paths, and at the same time:
- swallow some internal errors into logs and serve sanitized errors
- move some of the internal service implementations to also use gRPC statuses
- change a panic() call into a status.Unimplemented return type
There's still plenty work to be done on this front, but this is a good first change.
Test Plan: if this is not covered by tests we're screwed anyways
X-Origin-Diff: phab/D366
GitOrigin-RevId: 71880a9e23c65631d6c4df6338855864c34bb11f
diff --git a/core/internal/api/BUILD.bazel b/core/internal/api/BUILD.bazel
index 3daa397..e7ec6f8 100644
--- a/core/internal/api/BUILD.bazel
+++ b/core/internal/api/BUILD.bazel
@@ -16,7 +16,9 @@
"//core/internal/common/service:go_default_library",
"//core/internal/consensus:go_default_library",
"@org_golang_google_grpc//:go_default_library",
+ "@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//reflection:go_default_library",
+ "@org_golang_google_grpc//status:go_default_library",
"@org_uber_go_zap//:go_default_library",
],
)