File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,10 @@ import (
6
6
"encoding/json"
7
7
"errors"
8
8
"fmt"
9
-
9
+ "log"
10
10
"oauth-password/pkg/database"
11
11
"oauth-password/pkg/oauth"
12
+ "strings"
12
13
)
13
14
14
15
type Repository struct {
@@ -37,11 +38,17 @@ func (r *Repository) InsertSingle(
37
38
38
39
_ , err = r .client .ExecContext (
39
40
ctx ,
40
- `INSERT INTO public. client_credential (id, data) VALUES (DEFAULT, $1)` ,
41
+ `INSERT INTO client_credential (id, data) VALUES (DEFAULT, $1)` ,
41
42
data ,
42
43
)
43
44
if err != nil {
44
- return nil , err
45
+ if strings .Contains (err .Error (), `duplicate key value violates unique constraint "client_credential_username_idx"` ) {
46
+ return nil , fmt .Errorf (`username already exists` )
47
+ }
48
+
49
+ log .Println (clientCredential .Username , err )
50
+
51
+ return nil , errors .New ("unexpected error during insertion of new client" )
45
52
}
46
53
47
54
return & Entity {
You can’t perform that action at this time.
0 commit comments