@@ -40,6 +40,14 @@ type driverError struct {
40
40
message string
41
41
}
42
42
43
+ type sessionExpiredError struct {
44
+ message string
45
+ }
46
+
47
+ func (failure * databaseError ) BoltError () bool {
48
+ return true
49
+ }
50
+
43
51
func (failure * databaseError ) Classification () string {
44
52
return failure .classification
45
53
}
@@ -56,6 +64,10 @@ func (failure *databaseError) Error() string {
56
64
return fmt .Sprintf ("database returned error [%s]: %s" , failure .code , failure .message )
57
65
}
58
66
67
+ func (failure * connectorError ) BoltError () bool {
68
+ return true
69
+ }
70
+
59
71
func (failure * connectorError ) State () int {
60
72
return failure .state
61
73
}
@@ -72,10 +84,26 @@ func (failure *connectorError) Error() string {
72
84
return fmt .Sprintf ("expected connection to be in READY state, where it is %d [error is %d]" , failure .state , failure .code )
73
85
}
74
86
87
+ func (failure * driverError ) BoltError () bool {
88
+ return true
89
+ }
90
+
91
+ func (failure * driverError ) Message () string {
92
+ return failure .message
93
+ }
94
+
75
95
func (failure * driverError ) Error () string {
76
96
return failure .message
77
97
}
78
98
99
+ func (failure * sessionExpiredError ) BoltError () bool {
100
+ return true
101
+ }
102
+
103
+ func (failure * sessionExpiredError ) Error () string {
104
+ return failure .message
105
+ }
106
+
79
107
func newDriverError (format string , args ... interface {}) gobolt.GenericError {
80
108
return & driverError {message : fmt .Sprintf (format , args ... )}
81
109
}
@@ -92,20 +120,42 @@ func isRetriableError(err error) bool {
92
120
return gobolt .IsServiceUnavailable (err ) || gobolt .IsTransientError (err ) || gobolt .IsWriteError (err )
93
121
}
94
122
95
- // IsServiceUnavailable is a utility method to check if the provided error can be classified
96
- // to be in service unavailable category.
97
- func IsServiceUnavailable (err error ) bool {
98
- return gobolt .IsServiceUnavailable (err )
123
+ // IsSecurityError is a utility method to check if the provided error is related with any
124
+ // TLS failure or authentication issues.
125
+ func IsSecurityError (err error ) bool {
126
+ return gobolt .IsSecurityError (err )
127
+ }
128
+
129
+ // IsAuthenticationError is a utility method to check if the provided error is related with any
130
+ // authentication issues.
131
+ func IsAuthenticationError (err error ) bool {
132
+ return gobolt .IsAuthenticationError (err )
99
133
}
100
134
101
- // IsDriverError is a utility method to check if the provided error is generated by the driver
102
- func IsDriverError ( err error ) bool {
103
- _ , ok := err .( * driverError )
104
- return ok
135
+ // IsClientError is a utility method to check if the provided error is related with the client
136
+ // carrying out an invalid operation.
137
+ func IsClientError ( err error ) bool {
138
+ return gobolt . IsClientError ( err )
105
139
}
106
140
107
- // IsTransientError is a utility method to check if the provided error is a DatabaseError with
108
- // TransientError classification
141
+ // IsTransientError is a utility method to check if the provided error is related with a temporary
142
+ // failure that may be worked around by retrying.
109
143
func IsTransientError (err error ) bool {
110
144
return gobolt .IsTransientError (err )
111
145
}
146
+
147
+ // IsSessionExpired is a utility method to check if the session no longer satisfy the criteria
148
+ // under which it was acquired, e.g. a server no longer accepts write requests.
149
+ func IsSessionExpired (err error ) bool {
150
+ if _ , ok := err .(* sessionExpiredError ); ok {
151
+ return true
152
+ }
153
+
154
+ return gobolt .IsSessionExpired (err )
155
+ }
156
+
157
+ // IsServiceUnavailable is a utility method to check if the provided error can be classified
158
+ // to be in service unavailable category.
159
+ func IsServiceUnavailable (err error ) bool {
160
+ return gobolt .IsServiceUnavailable (err )
161
+ }
0 commit comments