-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy patherror.go
1000 lines (842 loc) · 30.9 KB
/
error.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package gocb
import (
"fmt"
"strings"
gocbcore "github.com/couchbase/gocbcore/v8"
"github.com/pkg/errors"
)
type retryAbleError interface {
retryable() bool
}
// KeyValueError represents an error that occurred while
// executing a K/V operation. Assumes that the service has returned a response.
type KeyValueError interface {
error
ID() string
StatusCode() int // ?
Opaque() uint32
KVError() bool
}
type kvError struct {
id string
status gocbcore.StatusCode
description string
opaque uint32
context string
ref string
name string
}
func (err kvError) Error() string {
if err.context != "" && err.ref != "" {
return fmt.Sprintf("%s (%s, context: %s, ref: %s)", err.description, err.name, err.context, err.ref)
} else if err.context != "" {
return fmt.Sprintf("%s (%s, context: %s)", err.description, err.name, err.context)
} else if err.ref != "" {
return fmt.Sprintf("%s (%s, ref: %s)", err.description, err.name, err.ref)
} else if err.name != "" && err.description != "" {
return fmt.Sprintf("%s (%s)", err.description, err.name)
} else if err.description != "" {
return err.description
}
return fmt.Sprintf("an unknown error occurred (%d)", err.status)
}
// StatusCode returns the memcached response status.
func (err kvError) StatusCode() int {
return int(err.status)
}
// ID returns the ID of the document used for the operation that yielded the error.
func (err kvError) ID() string {
return err.id
}
// Opaque is the unique identifier for the operation that yielded the error.
func (err kvError) Opaque() uint32 {
return err.opaque
}
// KVError specifies whether or not this is a KVError.
func (err kvError) KVError() bool {
return true
}
// IsScopeMissingError verifies whether or not the cause for an error is scope unknown
func IsScopeMissingError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusScopeUnknown)
}
return false
}
// IsCollectionMissingError verifies whether or not the cause for an error is scope unknown
func IsCollectionMissingError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusCollectionUnknown)
}
return false
}
// IsKeyExistsError indicates whether the passed error is a
// key-value "Key Already Exists" error.
func IsKeyExistsError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusKeyExists)
}
return false
}
// IsKeyNotFoundError indicates whether the passed error is a
// key-value "Key Not Found" error.
func IsKeyNotFoundError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusKeyNotFound)
}
return false
}
// IsTempFailError indicates whether the passed error is a
// key-value "temporary failure, try again later" error.
func IsTempFailError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusTmpFail)
}
return false
}
// IsValueTooBigError indicates whether the passed error is a
// key-value "document value was too large" error.
func IsValueTooBigError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusTooBig)
}
return false
}
// IsKeyLockedError indicates whether the passed error is a
// key-value operation failed due to the document being locked.
func IsKeyLockedError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusLocked)
}
return false
}
// IsPathNotFoundError indicates whether the passed error is a
// key-value "sub-document path does not exist" error.
func IsPathNotFoundError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusSubDocPathNotFound)
}
return false
}
// IsPathExistsError indicates whether the passed error is a
// key-value "given path already exists in the document" error.
func IsPathExistsError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusSubDocPathExists)
}
return false
}
// IsInvalidRangeError indicates whether the passed error is a
// key-value "requested value is outside range" error.
func IsInvalidRangeError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusRangeError)
}
return false
}
// IsHTTPError indicates whether the passed error is a
// HTTP error.
func IsHTTPError(err error) bool {
cause := errors.Cause(err)
if nErr, ok := cause.(HTTPError); ok {
return nErr.HTTPError()
}
return false
}
// IsNetworkError indicates whether the passed error is a
// network error.
func IsNetworkError(err error) bool {
cause := errors.Cause(err)
if nErr, ok := cause.(NetworkError); ok {
return nErr.NetworkError()
}
return false
}
// IsServiceNotFoundError indicates whether the passed error occurred due to
// the requested service not being found.
func IsServiceNotFoundError(err error) bool {
cause := errors.Cause(err)
if nErr, ok := cause.(ServiceNotFoundError); ok {
return nErr.ServiceNotFoundError()
}
return false
}
// IsTimeoutError verifies whether or not the cause for an error is a timeout.
func IsTimeoutError(err error) bool {
switch errType := errors.Cause(err).(type) {
case TimeoutError:
return errType.Timeout()
default:
return false
}
}
// IsPartialResultsError indicates whether or not the response returned error(s) but also contains data.
func IsPartialResultsError(err error) bool {
switch errType := errors.Cause(err).(type) {
case PartialResultError:
return errType.PartialResults()
default:
return false
}
}
// IsAuthenticationError verifies whether or not the cause for an error is an authentication error.
func IsAuthenticationError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusAuthError)
}
return false
}
// IsBucketMissingError verifies whether or not the cause for an error is a bucket missing error.
func IsBucketMissingError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusNoBucket)
}
return false
}
// IsAccessError verifies whether or not the cause for an error is an access error.
func IsAccessError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusAccessError)
}
return false
}
// IsConfigurationError verifies whether or not the cause for an error is a configuration error.
func IsConfigurationError(err error) bool {
switch errType := errors.Cause(err).(type) {
case ConfigurationError:
return errType.ConfigurationError()
default:
return false
}
}
// IsSubdocPathNotFoundError verifies whether or not the cause for an error is due to a subdoc operation path not found.
func IsSubdocPathNotFoundError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusSubDocPathNotFound)
}
return false
}
// IsSubdocPathExistsError verifies whether or not the cause for an error is due to a subdoc operation path exists
func IsSubdocPathExistsError(err error) bool {
cause := errors.Cause(err)
if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
return kvErr.StatusCode() == int(gocbcore.StatusSubDocPathExists)
}
return false
}
// IsDurabilityError verifies whether or not the cause for an error is due to a durability error.
func IsDurabilityError(err error) bool {
switch errType := errors.Cause(err).(type) {
case DurabilityError:
return errType.DurabilityError()
default:
return false
}
}
type clientError struct {
message string
}
func (e clientError) Error() string {
return e.message
}
// DurabilityError occurs when an error occurs during performing durability operations.
type DurabilityError interface {
DurabilityError() bool
}
type durabilityError struct {
reason string
}
func (err durabilityError) Error() string {
return err.reason
}
func (err durabilityError) DurabilityError() bool {
return true
}
// TimeoutError occurs when an operation times out.
type TimeoutError interface {
Timeout() bool
}
type timeoutError struct {
}
func (err timeoutError) Error() string {
return "operation timed out"
}
func (err timeoutError) Timeout() bool {
return true
}
// PartialResultError indicates that an error occurred but that data was also returned.
type PartialResultError interface {
PartialResults() bool
}
// ServiceNotFoundError is a generic error for HTTP errors.
type ServiceNotFoundError interface {
error
ServiceNotFoundError() bool
}
type serviceNotFoundError struct {
}
func (e serviceNotFoundError) Error() string {
return fmt.Sprintf("the service requested is not enabled or cannot be found on the node requested")
}
// ServiceNotFoundError returns whether or not the error is a service not found error.
func (e serviceNotFoundError) ServiceNotFoundError() bool {
return true
}
// HTTPError occurs when there is a http error.
type HTTPError interface {
error
StatusCode() int
HTTPError() bool
retryable() bool
}
type httpError struct {
message string
statusCode int
isRetryable bool
}
func (e httpError) Error() string {
if e.statusCode > 0 && e.message != "" {
return fmt.Sprintf("a http error occurred with status code: %d and message: %s", e.statusCode, e.message)
} else if e.statusCode > 0 {
return fmt.Sprintf("a http error occurred with status code: %d", e.statusCode)
} else if e.message != "" {
return fmt.Sprintf("a http error occurred with message: %s", e.message)
}
return fmt.Sprintf("a http error occurred")
}
// StatusCode returns the HTTP status code for the error, only applicable to HTTP services.
func (e httpError) StatusCode() int {
return e.statusCode
}
// HTTPError returns whether or not the error is a http error.
func (e httpError) HTTPError() bool {
return true
}
func (e httpError) retryable() bool {
return e.isRetryable
}
// NetworkError occurs when there is a network error.
type NetworkError interface {
error
NetworkError() bool
retryable() bool
}
type networkError struct {
message string
isRetryable bool
}
func (e networkError) Error() string {
return fmt.Sprintf("a network error occurred with message: %s", e.message)
}
// NetworkError returns whether or not the error is a network error.
func (e networkError) NetworkError() bool {
return true
}
func (e networkError) retryable() bool {
return e.isRetryable
}
// ProjectionErrors is a collection of one or more KeyValueError that occurs during a Get with projections operation.
type ProjectionErrors interface {
error
Errors() []KeyValueError
ProjectionErrors() bool
}
type projectionErrors struct {
errors []KeyValueError
}
func (e projectionErrors) ProjectionErrors() bool {
return true
}
func (e projectionErrors) Error() string {
var errs []string
for _, err := range e.errors {
errs = append(errs, err.Error())
}
return strings.Join(errs, ", ")
}
// ViewQueryError is the error type for an error that occurs during view query execution.
type ViewQueryError interface {
error
Reason() string
Message() string
}
type viewError struct {
ErrorMessage string `json:"message"`
ErrorReason string `json:"reason"`
}
func (e *viewError) Error() string {
return e.ErrorMessage + " - " + e.ErrorReason
}
// Reason is the reason for the error occurring.
func (e *viewError) Reason() string {
return e.ErrorReason
}
// Message contains any message from the server for this error.
func (e *viewError) Message() string {
return e.ErrorMessage
}
// ViewQueryErrors is a collection of one or more ViewQueryError that occurs for errors created by Couchbase Server
// during View query execution.
type ViewQueryErrors interface {
error
Errors() []ViewQueryError
HTTPStatus() int
Endpoint() string
PartialResults() bool
}
type viewMultiError struct {
errors []ViewQueryError
httpStatus int
endpoint string
partial bool
}
func (e viewMultiError) Error() string {
var errs []string
for _, err := range e.errors {
errs = append(errs, err.Error())
}
return strings.Join(errs, ", ")
}
// HTTPStatus returns the HTTP status code for the operation.
func (e viewMultiError) HTTPStatus() int {
return e.httpStatus
}
// Endpoint returns the endpoint that was used for the operation.
func (e viewMultiError) Endpoint() string {
return e.endpoint
}
// Errors returns the list of ViewQueryErrors.
func (e viewMultiError) Errors() []ViewQueryError {
return e.errors
}
// PartialResults indicates whether or not the operation also yielded results.
func (e viewMultiError) PartialResults() bool {
return e.partial
}
// AnalyticsQueryError occurs for errors created by Couchbase Server during Analytics query execution.
type AnalyticsQueryError interface {
error
Code() uint32
Message() string
}
type analyticsQueryError struct {
ErrorCode uint32 `json:"code"`
ErrorMessage string `json:"msg"`
}
func (e analyticsQueryError) Error() string {
return fmt.Sprintf("[%d] %s", e.ErrorCode, e.ErrorMessage)
}
// Code returns the error code for this error.
func (e analyticsQueryError) Code() uint32 {
return e.ErrorCode
}
// Message returns any message from the server for this error.
func (e analyticsQueryError) Message() string {
return e.ErrorMessage
}
func (e analyticsQueryError) retryable() bool {
if e.Code() != 21002 && e.Code() != 23000 && e.Code() != 23003 && e.Code() != 23007 {
return true
}
return false
}
// AnalyticsQueryErrors is a collection of one or more AnalyticsQueryError that occurs for errors created by Couchbase Server
// during Analytics query execution.
type AnalyticsQueryErrors interface {
error
Errors() []AnalyticsQueryError
HTTPStatus() int
Endpoint() string
ContextID() string
}
type analyticsQueryMultiError struct {
errors []AnalyticsQueryError
httpStatus int
endpoint string
contextID string
}
func (e analyticsQueryMultiError) retryable() bool {
for _, aErr := range e.errors {
if isRetryableError(aErr) {
return true
}
}
return false
}
func (e analyticsQueryMultiError) Error() string {
var errs []string
for _, err := range e.errors {
errs = append(errs, err.Error())
}
return strings.Join(errs, ", ")
}
// HTTPStatus returns the HTTP status code for the operation.
func (e analyticsQueryMultiError) HTTPStatus() int {
return e.httpStatus
}
// Endpoint returns the endpoint that was used for the operation.
func (e analyticsQueryMultiError) Endpoint() string {
return e.endpoint
}
// ContextID returns the context ID that was used for the operation.
func (e analyticsQueryMultiError) ContextID() string {
return e.contextID
}
// Errors returns the list of AnalyticsQueryErrors.
func (e analyticsQueryMultiError) Errors() []AnalyticsQueryError {
return e.errors
}
// QueryError occurs for errors created by Couchbase Server during N1ql query execution.
type QueryError interface {
error
Code() uint32
Message() string
}
type queryError struct {
ErrorCode uint32 `json:"code"`
ErrorMessage string `json:"msg"`
}
func (e queryError) Error() string {
return fmt.Sprintf("[%d] %s", e.ErrorCode, e.ErrorMessage)
}
// Code returns the error code for this error.
func (e queryError) Code() uint32 {
return e.ErrorCode
}
// Message returns any message from the server for this error.
func (e queryError) Message() string {
return e.ErrorMessage
}
func (e queryError) retryable() bool {
if e.ErrorCode == 4050 || e.ErrorCode == 4070 || e.ErrorCode == 5000 {
return true
}
return false
}
// QueryErrors is a collection of one or more QueryError that occurs for errors created by Couchbase Server
// during N1ql query execution.
type QueryErrors interface {
error
Errors() []QueryError
HTTPStatus() int
Endpoint() string
ContextID() string
}
type queryMultiError struct {
errors []QueryError
httpStatus int
endpoint string
contextID string
}
func (e queryMultiError) retryable() bool {
for _, n1qlErr := range e.errors {
if isRetryableError(n1qlErr) {
return true
}
}
return false
}
func (e queryMultiError) Error() string {
var errs []string
for _, err := range e.errors {
errs = append(errs, err.Error())
}
return strings.Join(errs, ", ")
}
// HTTPStatus returns the HTTP status code for the operation.
func (e queryMultiError) HTTPStatus() int {
return e.httpStatus
}
// Endpoint returns the endpoint that was used for the operation.
func (e queryMultiError) Endpoint() string {
return e.endpoint
}
// ContextID returns the context ID that was used for the operation.
func (e queryMultiError) ContextID() string {
return e.contextID
}
// Errors returns the list of AnalyticsQueryErrors.
func (e queryMultiError) Errors() []QueryError {
return e.errors
}
// SearchError occurs for errors created by Couchbase Server during Search query execution.
type SearchError interface {
error
Message() string
}
type searchError struct {
message string
}
func (e searchError) Error() string {
return e.message
}
// Message returns any message from the server for this error.
func (e searchError) Message() string {
return e.message
}
// SearchErrors is a collection of one or more SearchError that occurs for errors created by Couchbase Server
// during Search query execution.
type SearchErrors interface {
error
Errors() []SearchError
HTTPStatus() int
Endpoint() string
ContextID() string
PartialResults() bool
}
type searchMultiError struct {
errors []SearchError
httpStatus int
endpoint string
contextID string
partial bool
}
func (e searchMultiError) Error() string {
var errs []string
for _, err := range e.errors {
errs = append(errs, err.Error())
}
return strings.Join(errs, ", ")
}
// HTTPStatus returns the HTTP status code for the operation.
func (e searchMultiError) HTTPStatus() int {
return e.httpStatus
}
// Endpoint returns the endpoint that was used for the operation.
func (e searchMultiError) Endpoint() string {
return e.endpoint
}
// ContextID returns the context ID that was used for the operation.
func (e searchMultiError) ContextID() string {
return e.contextID
}
// Errors returns the list of SearchErrors.
func (e searchMultiError) Errors() []SearchError {
return e.errors
}
// PartialResults indicates whether or not the operation also yielded results.
func (e searchMultiError) PartialResults() bool {
return e.partial
}
// ConfigurationError occurs when the client is configured incorrectly.
type ConfigurationError interface {
error
ConfigurationError() bool
}
type configurationError struct {
message string
}
func (e configurationError) Error() string {
return e.message
}
// ConfigurationError indicates whether or not this error is a ConfigurationError
func (e configurationError) ConfigurationError() bool {
return true
}
// ErrorCause returns the underlying cause of an error.
func ErrorCause(err error) error {
return errors.Cause(err)
}
func isRetryableError(err error) bool {
switch errType := errors.Cause(err).(type) {
case retryAbleError:
return errType.retryable()
default:
return false
}
}
func maybeEnhanceErr(err error, key string) error {
cause := errors.Cause(err)
switch errType := cause.(type) {
case *gocbcore.KvError:
return kvError{
id: key,
status: errType.Code,
description: errType.Description,
opaque: errType.Opaque,
context: errType.Context,
ref: errType.Ref,
name: errType.Name,
}
default:
}
if cause == gocbcore.ErrNetwork {
return networkError{}
}
return err
}
func errIsGocbcoreInvalidService(err error) bool {
return err == gocbcore.ErrNoCapiService ||
err == gocbcore.ErrNoCbasService ||
err == gocbcore.ErrNoFtsService ||
err == gocbcore.ErrNoN1qlService
}
var (
// ErrNotEnoughReplicas occurs when not enough replicas exist to match the specified durability requirements.
// ErrNotEnoughReplicas = errors.New("Not enough replicas to match durability requirements.")
// ErrDurabilityTimeout occurs when the server took too long to meet the specified durability requirements.
// ErrDurabilityTimeout = errors.New("Failed to meet durability requirements in time.")
// ErrNoResults occurs when no results are available to a query.
ErrNoResults = errors.New("No results returned.")
// ErrNoOpenBuckets occurs when a cluster-level operation is performed before any buckets are opened.
ErrNoOpenBuckets = errors.New("You must open a bucket before you can perform cluster level operations.")
// ErrIndexInvalidName occurs when an invalid name was specified for an index.
ErrIndexInvalidName = errors.New("An invalid index name was specified.")
// ErrIndexNoFields occurs when an index with no fields is created.
ErrIndexNoFields = errors.New("You must specify at least one field to index.")
// ErrIndexNotFound occurs when an operation expects an index but it was not found.
ErrIndexNotFound = errors.New("The index specified does not exist.")
// ErrIndexAlreadyExists occurs when an operation expects an index not to exist, but it was found.
ErrIndexAlreadyExists = errors.New("The index specified already exists.")
// ErrFacetNoRanges occurs when a range-based facet is specified but no ranges were indicated.
ErrFacetNoRanges = errors.New("At least one range must be specified on a facet.")
// ErrSearchIndexInvalidName occurs when an invalid name was specified for a search index.
ErrSearchIndexInvalidName = errors.New("An invalid search index name was specified.")
// ErrSearchIndexMissingType occurs when no type was specified for a search index.
ErrSearchIndexMissingType = errors.New("No search index type was specified.")
// ErrSearchIndexInvalidSourceType occurs when an invalid source type was specific for a search index.
ErrSearchIndexInvalidSourceType = errors.New("An invalid search index source type was specified.")
// ErrSearchIndexInvalidSourceName occurs when an invalid source name was specific for a search index.
ErrSearchIndexInvalidSourceName = errors.New("An invalid search index source name was specified.")
// ErrSearchIndexAlreadyExists occurs when an invalid source name was specific for a search index.
ErrSearchIndexAlreadyExists = errors.New("The search index specified already exists.")
// ErrSearchIndexInvalidIngestControlOp occurs when an invalid ingest control op was specific for a search index.
ErrSearchIndexInvalidIngestControlOp = errors.New("An invalid search index ingest control op was specified.")
// ErrSearchIndexInvalidQueryControlOp occurs when an invalid query control op was specific for a search index.
ErrSearchIndexInvalidQueryControlOp = errors.New("An invalid search index query control op was specified.")
// ErrSearchIndexInvalidPlanFreezeControlOp occurs when an invalid plan freeze control op was specific for a search index.
ErrSearchIndexInvalidPlanFreezeControlOp = errors.New("An invalid search index plan freeze control op was specified.")
// ErrDispatchFail occurs when we failed to execute an operation due to internal routing issues.
ErrDispatchFail = gocbcore.ErrDispatchFail
// ErrBadHosts occurs when an invalid list of hosts is specified for bootstrapping.
ErrBadHosts = gocbcore.ErrBadHosts
// ErrProtocol occurs when an invalid protocol is specified for bootstrapping.
ErrProtocol = gocbcore.ErrProtocol
// ErrNoReplicas occurs when an operation expecting replicas is performed, but no replicas are available.
ErrNoReplicas = gocbcore.ErrNoReplicas
// ErrInvalidServer occurs when a specified server index is invalid.
ErrInvalidServer = gocbcore.ErrInvalidServer
// ErrInvalidVBucket occurs when a specified vbucket index is invalid.
ErrInvalidVBucket = gocbcore.ErrInvalidVBucket
// ErrInvalidReplica occurs when a specified replica index is invalid.
ErrInvalidReplica = gocbcore.ErrInvalidReplica
// ErrInvalidCert occurs when the specified certificate is not valid.
ErrInvalidCert = gocbcore.ErrInvalidCert
// ErrInvalidCredentials is returned when an invalid set of credentials is provided for a service.
ErrInvalidCredentials = gocbcore.ErrInvalidCredentials
// ErrNonZeroCas occurs when an operation that require a CAS value of 0 is used with a non-zero value.
ErrNonZeroCas = gocbcore.ErrNonZeroCas
// ErrShutdown occurs when an operation is performed on a bucket that has been closed.
ErrShutdown = gocbcore.ErrShutdown
// ErrOverload occurs when more operations were dispatched than the client is capable of writing.
ErrOverload = gocbcore.ErrOverload
// // ErrNetwork occurs when various generic network errors occur.
// ErrNetwork = gocbcore.ErrNetwork
// // ErrTimeout occurs when an operation times out.
// ErrTimeout = gocbcore.ErrTimeout
// ErrCliInternalError indicates an internal error occurred within the client.
// ErrCliInternalError = gocbcore.ErrCliInternalError
// // ErrStreamClosed occurs when an error is related to a stream closing.
// ErrStreamClosed = gocbcore.ErrStreamClosed
// // ErrStreamStateChanged occurs when an error is related to a cluster rebalance.
// ErrStreamStateChanged = gocbcore.ErrStreamStateChanged
// // ErrStreamDisconnected occurs when a stream is closed due to a connection dropping.
// ErrStreamDisconnected = gocbcore.ErrStreamDisconnected
// // ErrStreamTooSlow occurs when a stream is closed due to being too slow at consuming data.
// ErrStreamTooSlow = gocbcore.ErrStreamTooSlow
// // ErrKeyNotFound occurs when the key is not found on the server.
// ErrKeyNotFound = gocbcore.ErrKeyNotFound
// // ErrKeyExists occurs when the key already exists on the server.
// ErrKeyExists = gocbcore.ErrKeyExists
// // ErrTooBig occurs when the document is too big to be stored.
// ErrTooBig = gocbcore.ErrTooBig
// // ErrNotStored occurs when an item fails to be stored. Usually an append/prepend to missing key.
// ErrNotStored = gocbcore.ErrNotStored
// // ErrAuthError occurs when there is an issue with authentication (bad password?).
// ErrAuthError = gocbcore.ErrAuthError
// // ErrRangeError occurs when an invalid range is specified.
// ErrRangeError = gocbcore.ErrRangeError
// // ErrRollback occurs when a server rollback has occurred making the operation no longer valid.
// ErrRollback = gocbcore.ErrRollback
// // ErrAccessError occurs when you do not have access to the specified resource.
// ErrAccessError = gocbcore.ErrAccessError
// // ErrOutOfMemory occurs when the server has run out of memory to process requests.
// ErrOutOfMemory = gocbcore.ErrOutOfMemory
// // ErrNotSupported occurs when an operation is performed which is not supported.
// ErrNotSupported = gocbcore.ErrNotSupported
// // ErrInternalError occurs when an internal error has prevented an operation from succeeding.
// ErrInternalError = gocbcore.ErrInternalError
// // ErrBusy occurs when the server is too busy to handle your operation.
// ErrBusy = gocbcore.ErrBusy
// // ErrTmpFail occurs when the server is not immediately able to handle your request.
// ErrTmpFail = gocbcore.ErrTmpFail
// // ErrSubDocPathNotFound occurs when a sub-document operation targets a path
// // which does not exist in the specifie document.
// ErrSubDocPathNotFound = gocbcore.ErrSubDocPathNotFound
// // ErrSubDocPathMismatch occurs when a sub-document operation specifies a path
// // which does not match the document structure (field access on an array).
// ErrSubDocPathMismatch = gocbcore.ErrSubDocPathMismatch
// // ErrSubDocPathInvalid occurs when a sub-document path could not be parsed.
// ErrSubDocPathInvalid = gocbcore.ErrSubDocPathInvalid
// // ErrSubDocPathTooBig occurs when a sub-document path is too big.
// ErrSubDocPathTooBig = gocbcore.ErrSubDocPathTooBig
// // ErrSubDocDocTooDeep occurs when an operation would cause a document to be
// // nested beyond the depth limits allowed by the sub-document specification.
// ErrSubDocDocTooDeep = gocbcore.ErrSubDocDocTooDeep
// // ErrSubDocCantInsert occurs when a sub-document operation could not insert.
// ErrSubDocCantInsert = gocbcore.ErrSubDocCantInsert
// // ErrSubDocNotJson occurs when a sub-document operation is performed on a
// // document which is not JSON.
// ErrSubDocNotJson = gocbcore.ErrSubDocNotJson
// // ErrSubDocBadRange occurs when a sub-document operation is performed with
// // a bad range.
// ErrSubDocBadRange = gocbcore.ErrSubDocBadRange
// // ErrSubDocBadDelta occurs when a sub-document counter operation is performed
// // and the specified delta is not valid.
// ErrSubDocBadDelta = gocbcore.ErrSubDocBadDelta
// // ErrSubDocPathExists occurs when a sub-document operation expects a path not
// // to exists, but the path was found in the document.
// ErrSubDocPathExists = gocbcore.ErrSubDocPathExists
// // ErrSubDocValueTooDeep occurs when a sub-document operation specifies a value
// // which is deeper than the depth limits of the sub-document specification.
// ErrSubDocValueTooDeep = gocbcore.ErrSubDocValueTooDeep
// // ErrSubDocBadCombo occurs when a multi-operation sub-document operation is
// // performed and operations within the package of ops conflict with each other.
// ErrSubDocBadCombo = gocbcore.ErrSubDocBadCombo
// // ErrSubDocBadMulti occurs when a multi-operation sub-document operation is
// // performed and operations within the package of ops conflict with each other.
// ErrSubDocBadMulti = gocbcore.ErrSubDocBadMulti
// // ErrSubDocSuccessDeleted occurs when a multi-operation sub-document operation
// // is performed on a soft-deleted document.
// ErrSubDocSuccessDeleted = gocbcore.ErrSubDocSuccessDeleted
// ErrSubDocXattrInvalidFlagCombo occurs when an invalid set of
// extended-attribute flags is passed to a sub-document operation.
// ErrSubDocXattrInvalidFlagCombo = gocbcore.ErrSubDocXattrInvalidFlagCombo
// // ErrSubDocXattrInvalidKeyCombo occurs when an invalid set of key operations
// // are specified for a extended-attribute sub-document operation.
// ErrSubDocXattrInvalidKeyCombo = gocbcore.ErrSubDocXattrInvalidKeyCombo
// // ErrSubDocXattrUnknownMacro occurs when an invalid macro value is specified.
// ErrSubDocXattrUnknownMacro = gocbcore.ErrSubDocXattrUnknownMacro
// // ErrSubDocXattrUnknownVAttr occurs when an invalid virtual attribute is specified.
// ErrSubDocXattrUnknownVAttr = gocbcore.ErrSubDocXattrUnknownVAttr
// // ErrSubDocXattrCannotModifyVAttr occurs when a mutation is attempted upon
// // a virtual attribute (which are immutable by definition).
// ErrSubDocXattrCannotModifyVAttr = gocbcore.ErrSubDocXattrCannotModifyVAttr
// // ErrSubDocMultiPathFailureDeleted occurs when a Multi Path Failure occurs on
// // a soft-deleted document.
// ErrSubDocMultiPathFailureDeleted = gocbcore.ErrSubDocMultiPathFailureDeleted
)