-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patherrors.go
68 lines (51 loc) · 1.98 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
package loafergo
import (
"fmt"
)
// Error defines the error handler for the loafergo package. Error satisfies the error interface and can be
// used safely with other error handlers
type Error struct {
contextErr error
Err string `json:"err"`
}
// Error is used for implementing the error interface, and for creating
// a proper error string
func (e *Error) Error() string {
if e.contextErr != nil {
return fmt.Sprintf("%s: %s", e.Err, e.contextErr.Error())
}
return e.Err
}
// Context is used for creating a new instance of the error with the contextual error attached
func (e *Error) Context(err error) *Error {
ctxErr := new(Error)
*ctxErr = *e
ctxErr.contextErr = err
return ctxErr
}
// newError creates a new SQS Error
func newError(msg string) *Error {
e := new(Error)
e.Err = msg
return e
}
// ErrInvalidCreds invalid credentials
var ErrInvalidCreds = newError("invalid aws credentials")
// ErrMarshal unable to marshal request
var ErrMarshal = newError("unable to marshal request")
// ErrNoRoute message received without a route
var ErrNoRoute = newError("message received without a route")
// ErrGetMessage fires when a request to retrieve messages from sqs fails
var ErrGetMessage = newError("unable to retrieve message")
// ErrMessageProcessing occurs when a message has exceeded the consumption time limit set by aws SQS
var ErrMessageProcessing = newError("processing time exceeding limit")
// ErrNoSQSClient occurs when the sqs client is nil
var ErrNoSQSClient = newError("sqs client is nil")
// ErrNoHandler occurs when the handler is nil
var ErrNoHandler = newError("handler is nil")
// ErrEmptyParam occurs when the required parameter is missing
var ErrEmptyParam = newError("required parameter is missing")
// ErrEmptyRequiredField occurs when the required field is missing
var ErrEmptyRequiredField = newError("required field is missing")
// ErrEmptyInput occurs when the producer received an empty or nil input
var ErrEmptyInput = newError("input must be filled")