-
Notifications
You must be signed in to change notification settings - Fork 18
/
errs.go
87 lines (65 loc) · 2.76 KB
/
errs.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
package gosqs
import (
"fmt"
"log"
)
// Logger provides a simple interface to implement your own logging platform or use the default
type Logger interface {
Println(v ...interface{})
}
type defaultLogger struct{}
func (dl *defaultLogger) Println(v ...interface{}) {
log.Println(v...)
}
// SQSError defines the error handler for the gosqs package. SQSError satisfies the error interface and can be
// used safely with other error handlers
type SQSError struct {
Err string `json:"err"`
// contextErr passes the actual error as part of the error message
contextErr error
}
// Error is used for implementing the error interface, and for creating
// a proper error string
func (e *SQSError) 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 *SQSError) Context(err error) *SQSError {
ctxErr := new(SQSError)
*ctxErr = *e
ctxErr.contextErr = err
return ctxErr
}
// newSQSErr creates a new SQS Error
func newSQSErr(msg string) *SQSError {
e := new(SQSError)
e.Err = msg
return e
}
// ErrUndefinedPublisher invalid credentials
var ErrUndefinedPublisher = newSQSErr("sqs publisher is undefined")
// ErrInvalidCreds invalid credentials
var ErrInvalidCreds = newSQSErr("invalid aws credentials")
// ErrUnableToDelete unable to delete item
var ErrUnableToDelete = newSQSErr("unable to delete item in queue")
// ErrUnableToExtend unable to extend message processing time
var ErrUnableToExtend = newSQSErr("unable to extend message processing time")
// ErrQueueURL undefined queueURL
var ErrQueueURL = newSQSErr("undefined queueURL")
// ErrMarshal unable to marshal request
var ErrMarshal = newSQSErr("unable to marshal request")
// ErrInvalidVal the custom attribute value must match the type of the custom attribute Datatype
var ErrInvalidVal = newSQSErr("value type does not match specified datatype")
// ErrNoRoute message received without a route
var ErrNoRoute = newSQSErr("message received without a route")
// ErrGetMessage fires when a request to retrieve messages from sqs fails
var ErrGetMessage = newSQSErr("unable to retrieve message")
// ErrMessageProcessing occurs when a message has exceeded the consumption time limit set by aws SQS
var ErrMessageProcessing = newSQSErr("processing time exceeding limit")
// ErrBodyOverflow AWS SQS can only hold payloads of 262144 bytes. Messages must either be routed to s3 or truncated
var ErrBodyOverflow = newSQSErr("message surpasses sqs limit of 262144, please truncate body")
// ErrPublish If there is an error publishing a message. gosqs will wait 10 seconds and try again up to the configured retry count
var ErrPublish = newSQSErr("message publish failure. Retrying...")