-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy patherrors.go
68 lines (59 loc) · 1.73 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
// Tideland Go Cells - Errors
//
// Copyright (C) 2010-2017 Frank Mueller / Tideland / Oldenburg / Germany
//
// All rights reserved. Use of this source code is governed
// by the new BSD license.
package cells
//--------------------
// IMPORTS
//--------------------
import (
"github.com/tideland/golib/errors"
)
//--------------------
// CONSTANTS
//--------------------
// Error codes of the cells package.
const (
ErrCellInit = iota + 1
ErrCannotRecover
ErrCannotEmit
ErrDuplicateID
ErrInvalidID
ErrExecuteID
ErrEventRecovering
ErrRecoveredTooOften
ErrNoTopic
ErrMarshal
ErrUnmarshal
ErrInactive
ErrStopping
ErrTimeout
)
// Error messages of the cells package.
var errorMessages = map[int]string{
ErrCellInit: "cell %q cannot initialize",
ErrCannotRecover: "cannot recover cell %q: %v",
ErrCannotEmit: "cannot emit event into queue",
ErrDuplicateID: "cell with ID %q is already registered",
ErrInvalidID: "cell with ID %q does not exist",
ErrExecuteID: "cannot %s with cell %q",
ErrEventRecovering: "cell cannot recover after error %v",
ErrRecoveredTooOften: "cell needs too much recoverings, last error",
ErrNoTopic: "event has no topic",
ErrMarshal: "cannot marshal the payload",
ErrUnmarshal: "cannot unmarshal the payload",
ErrInactive: "cell %q is inactive",
ErrStopping: "%s is stopping",
ErrTimeout: "needed too long for %v",
}
//--------------------
// ERROR CHECKING
//--------------------
// NewCannotRecoverError returns an error showing that a cell cannot
// recover from errors.
func NewCannotRecoverError(id string, err interface{}) error {
return errors.New(ErrCannotRecover, errorMessages, id, err)
}
// EOF