Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-05-10 11:59:25 +0300
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-05-10 18:27:52 +0300
commitc78723080a59335892464b379dc02f186a5bf7e9 (patch)
tree77393c809761ae99e0d7c23754fe12d612544314 /internal/helper
parent2f88d5d9ab699e9ada65fd0ac6b376009ff3ab30 (diff)
Add helper.DecorateError
Diffstat (limited to 'internal/helper')
-rw-r--r--internal/helper/error.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/helper/error.go b/internal/helper/error.go
new file mode 100644
index 000000000..3c8c4b7f9
--- /dev/null
+++ b/internal/helper/error.go
@@ -0,0 +1,18 @@
+package helper
+
+import (
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+)
+
+// DecorateError unless it's already a grpc error.
+// If given nil it will return nil.
+func DecorateError(code codes.Code, err error) error {
+ if err != nil {
+ if grpc.Code(err) == codes.Unknown {
+ return grpc.Errorf(code, "%v", err)
+ }
+ return err
+ }
+ return nil
+}