This repository has been archived by the owner on Nov 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
errors.go
58 lines (52 loc) · 1.53 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
package rony
import (
"errors"
"fmt"
)
/*
Creation Time: 2019 - Nov - 16
Created by: (ehsan)
Maintainers:
1. Ehsan N. Moosa (E2)
Auditor: Ehsan N. Moosa (E2)
Copyright Ronak Software Group 2020
*/
// Error Codes
const (
ErrCodeInternal = "E00" // When Error is Unknown or it is internal and should not be exposed to the client
ErrCodeInvalid = "E01"
ErrCodeUnavailable = "E02"
ErrCodeTooMany = "E03"
ErrCodeTooFew = "E04"
ErrCodeIncomplete = "E05"
ErrCodeTimeout = "E06"
ErrCodeAccess = "E07"
ErrCodeAlreadyExists = "E08"
ErrCodeBusy = "E09"
ErrCodeOutOfRange = "E10"
ErrCodePartiallyApplied = "E11"
ErrCodeExpired = "E12"
ErrCodeNotImplemented = "E13"
)
// Error Items
const (
ErrItemServer = "SERVER"
ErrItemRaftLeader = "RAFT_LEADER"
ErrItemHandler = "HANDLER"
ErrItemRequest = "REQUEST"
)
// Errors
var (
ErrGatewayAlreadyInitialized = errors.New("gateway already initialized")
ErrNotFound = errors.New("not found")
ErrNotRaftLeader = errors.New("not raft leader")
ErrRaftAlreadyJoined = errors.New("raft already joined")
ErrRaftNotSet = errors.New("raft not set")
ErrRaftExecuteOnLeader = errors.New("raft execute on leader")
ErrRetriesExceeded = wrapError("maximum retries exceeded")
)
func wrapError(txt string) func(err error) error {
return func(err error) error {
return errors.New(fmt.Sprintf("%s: %v", txt, err))
}
}