forked from ssdb/gossdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresult.go
More file actions
38 lines (29 loc) · 645 Bytes
/
Copy pathresult.go
File metadata and controls
38 lines (29 loc) · 645 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package ssdb
import (
"fmt"
)
var (
ErrIsEmpty = fmt.Errorf("error: respone is empty")
ErrNotFound = fmt.Errorf("error: not found")
)
func ResultProcessing(resp Values, err error) (Values, error) {
if err != nil {
return nil, fmt.Errorf("error: %v", err.Error())
}
if len(resp) < 1 {
return nil, ErrIsEmpty
}
if resp[0].Equal(ok) {
if len(resp) < 2 {
return nil, nil
}
return resp[1:], nil
}
if resp[0].Equal(notFound) {
return nil, ErrNotFound
}
if resp[0].Equal(clientError) {
return nil, fmt.Errorf("error: client error: %v", resp.String())
}
return nil, fmt.Errorf("error: parameter: %v", resp[0])
}