forked from couchbase/gocb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error_view.go
42 lines (36 loc) · 1.34 KB
/
error_view.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
package gocb
import gocbcore "github.com/couchbase/gocbcore/v9"
// ViewErrorDesc represents a specific error returned from the views service.
type ViewErrorDesc struct {
SourceNode string
Message string
}
func translateCoreViewErrorDesc(descs []gocbcore.ViewQueryErrorDesc) []ViewErrorDesc {
descsOut := make([]ViewErrorDesc, len(descs))
for descIdx, desc := range descs {
descsOut[descIdx] = ViewErrorDesc{
SourceNode: desc.SourceNode,
Message: desc.Message,
}
}
return descsOut
}
// ViewError is the error type of all view query errors.
// UNCOMMITTED: This API may change in the future.
type ViewError struct {
InnerError error `json:"-"`
DesignDocumentName string `json:"design_document_name,omitempty"`
ViewName string `json:"view_name,omitempty"`
Errors []ViewErrorDesc `json:"errors,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
RetryReasons []RetryReason `json:"retry_reasons,omitempty"`
RetryAttempts uint32 `json:"retry_attempts,omitempty"`
}
// Error returns the string representation of this error.
func (e ViewError) Error() string {
return e.InnerError.Error() + " | " + serializeWrappedError(e)
}
// Unwrap returns the underlying cause for this error.
func (e ViewError) Unwrap() error {
return e.InnerError
}