forked from facebookarchive/zk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
97 lines (88 loc) · 3.1 KB
/
errors.go
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
package zk
import "fmt"
// Error is an error code returned in a ReplyHeader by a Zookeeper server.
type Error int32
func (e Error) Error() string {
if err, ok := errToString[e]; ok {
return err
}
return fmt.Sprintf("unknown error code: %d", e)
}
// ref: https://github.com/apache/zookeeper/blob/master/zookeeper-client/zookeeper-client-c/include/zookeeper.h#L94
const (
// System and server-side errors
errSys = -1
errRuntime = -2
errData = -3
errConnLoss = -4
errMarshal = -5
errUnimpl = -6
errTimeout = -7
errArgs = -8
errState = -9
errQuorum = -13
errCfgInProgress = -14
errSSL = -15
// API errors
errAPI Error = -100
errNoNode Error = -101
errNoAuth Error = -102
errBadVersion Error = -103
errNoChildren Error = -108
errNodeExists Error = -110
errNotEmpty Error = -111
errExpired Error = -112
errCallback Error = -113
errInvalidACL Error = -114
errAuthFailed Error = -115
errClosing Error = -116
errNothing Error = -117
errMoved Error = -118
errReadOnly Error = -119
errEphLocal Error = -120
errNoWatcher Error = -121
errReconfig Error = -123
errAuthScheme Error = -124
errThrottled Error = -127
)
var errToString = map[Error]string{
errSys: "system error",
errRuntime: "runtime inconsistency found",
errData: "data inconsistency found",
errConnLoss: "connection to the server has been lost",
errMarshal: "error while marshalling or unmarshalling data",
errUnimpl: "operation is unimplemented",
errTimeout: "operation timeout",
errArgs: "invalid arguments",
errState: "invalid zhandle state",
errQuorum: "no quorum of new config is connected",
errCfgInProgress: "reconfiguration requested while another is currently in progress",
errSSL: "SSL connection error",
errAPI: "api error",
errNoNode: "node does not exist",
errNoAuth: "not authenticated",
errBadVersion: "version conflict",
errNoChildren: "ephemeral nodes may not have children",
errNodeExists: "node already exists",
errNotEmpty: "node has children",
errExpired: "session has been expired by the server",
errCallback: "invalid callback specified",
errInvalidACL: "invalid ACL specified",
errAuthFailed: "client authentication failed",
errClosing: "zookeeper is closing",
errNothing: "no server responses to process",
errMoved: "session moved to another server, so operation is ignored",
errReadOnly: "state-changing request is passed to read-only server",
errEphLocal: "attempt to create ephemeral node on a local session",
errNoWatcher: "the watcher couldn't be found",
errReconfig: "attempts to perform a reconfiguration operation when it is disabled",
errAuthScheme: "server requires configured authentication scheme",
errThrottled: "operation was throttled and not executed at all",
}