Skip to content

Commit 452245e

Browse files
committed
better errors
1 parent 5608382 commit 452245e

File tree

8 files changed

+146
-104
lines changed

8 files changed

+146
-104
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.13.1
2+
current_version = 0.13.2
33
commit = False
44
tag = False
55

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version := "0.13.1"
1+
version := "0.13.2"
22

33
.DEFAULT_GOAL := help
44

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ https://graphikdb.github.io/graphik/
77

88
`git clone git@github.com:graphikDB/graphik.git`
99

10-
`docker pull graphikdb/graphik:v0.13.1`
10+
`docker pull graphikdb/graphik:v0.13.2`
1111

1212
Graphik is a Backend as a Service implemented as an identity-aware, permissioned, persistant document/graph database & pubsub server written in Go.
1313

@@ -910,7 +910,7 @@ add this docker-compose.yml to ${pwd}:
910910
version: '3.7'
911911
services:
912912
graphik:
913-
image: graphikdb/graphik:v0.13.1
913+
image: graphikdb/graphik:v0.13.2
914914
env_file:
915915
- .env
916916
ports:

database/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ var (
3232
ErrNotFound = errors.New("not found")
3333
ErrAlreadyExists = errors.New("already exists")
3434
ErrUnsupportedAlgorithm = errors.New("unsupported algorithm")
35+
ErrFailedToGetUser = errors.New("failed to get user")
3536
)

database/errors.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package database
2+
3+
import (
4+
"go.etcd.io/bbolt"
5+
"google.golang.org/grpc/codes"
6+
"google.golang.org/grpc/status"
7+
"strings"
8+
)
9+
10+
func prepareError(err error) error {
11+
if err == nil {
12+
return nil
13+
}
14+
_, ok := status.FromError(err)
15+
if !ok {
16+
if err == ErrNotFound {
17+
return status.Error(codes.NotFound, err.Error())
18+
}
19+
if err == ErrAlreadyExists {
20+
return status.Error(codes.InvalidArgument, err.Error())
21+
}
22+
if err == ErrUnsupportedAlgorithm {
23+
return status.Error(codes.InvalidArgument, err.Error())
24+
}
25+
if err == ErrFailedToGetUser {
26+
return status.Error(codes.Unauthenticated, err.Error())
27+
}
28+
if err == bbolt.ErrTimeout {
29+
return status.Error(codes.Internal, "internal error")
30+
}
31+
if strings.Contains(err.Error(), "does not exist") {
32+
return status.Error(codes.InvalidArgument, err.Error())
33+
}
34+
if strings.Contains(err.Error(), "trigger: ") {
35+
return status.Error(codes.InvalidArgument, err.Error())
36+
}
37+
38+
return status.Error(codes.Internal, err.Error())
39+
}
40+
return err
41+
}

0 commit comments

Comments
 (0)