-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy patherrors.go
86 lines (65 loc) · 2 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
package solr
import (
"fmt"
)
var ErrNotFound = NewNotFoundError("Not found")
type SolrError struct {
errorMessage string
}
func (err SolrError) Error() string {
return err.errorMessage
}
func NewSolrError(status int, message string) error {
return SolrError{errorMessage: fmt.Sprintf("received error response from solr status: %d message: %s", status, message)}
}
func NewSolrRFError(rf, minRF int) error {
return SolrMinRFError{SolrError{errorMessage: fmt.Sprintf("received error response from solr: rf (%d) is < min_rf (%d)", rf, minRF)}, rf}
}
type SolrMinRFError struct {
SolrError
MinRF int
}
type SolrInternalError struct {
SolrError
}
func NewSolrInternalError(status int, message string) error {
return SolrInternalError{SolrError{errorMessage: fmt.Sprintf("received error response from solr status: %d message: %s", status, message)}}
}
type SolrLeaderError struct {
SolrError
}
func NewSolrLeaderError(docID string) error {
return SolrLeaderError{SolrError{errorMessage: fmt.Sprintf("Cannot find leader for doc %s", docID)}}
}
type SolrBatchError struct {
error
}
func NewSolrBatchError(err error) error {
return SolrBatchError{error: err}
}
type SolrParseError struct {
SolrError
}
func NewSolrParseError(status int, message string) error {
return SolrInternalError{SolrError{errorMessage: fmt.Sprintf("received error response from solr status: %d message: %s", status, message)}}
}
type SolrMapParseError struct {
bucket string
m map[string]interface{}
userId int
}
func (err SolrMapParseError) Error() string {
return fmt.Sprintf("SolrMapParseErr: map does not contain email_register, bucket: %s, userId: %d map: %v", err.bucket, err.userId, err.m)
}
func NewSolrMapParseError(bucket string, userId int, m map[string]interface{}) error {
return SolrMapParseError{bucket, m, userId}
}
type NotFoundError struct {
errorMessage string
}
func (err NotFoundError) Error() string {
return err.errorMessage
}
func NewNotFoundError(error string) error {
return NotFoundError{errorMessage: error}
}