-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherrors.go
65 lines (54 loc) · 1.6 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
package cadeft
import (
"errors"
"fmt"
)
type ParseError struct {
Err error
Msg string
}
func (p *ParseError) Error() string {
if p.Err != nil {
return fmt.Errorf("%s: %w", p.Msg, p.Err).Error()
} else {
return p.Msg
}
}
func (p *ParseError) UnWrap() error {
return p.Err
}
func NewParseError(err error, msg string) error {
return &ParseError{
Err: err,
Msg: msg,
}
}
type ValidationError struct {
Err error
}
func (v *ValidationError) Error() string {
return v.Err.Error()
}
func (v *ValidationError) UnWrap() error {
return v.Err
}
func NewValidationError(err error) error {
return &ValidationError{
Err: err,
}
}
var (
// parse errors
ErrInvalidRecordLength = errors.New("transaction record is not 240 characters")
// Validation errors
ErrMissingOriginatorId = errors.New("missing originator ID")
ErrMissingCreationDate = errors.New("missing creation date")
ErrInvalidRecordType = errors.New("invalid record type")
ErrInvalidCurrencyCode = errors.New("invalid currency code")
ErrInvalidOriginatorIdLength = errors.New("invalid originator ID length")
ErrInvalidOriginatorId = errors.New("invalid originator ID not alpha numeric")
ErrInvalidFileCreationNum = errors.New("invalid file creation number")
ErrInvalidDestinationDataCenterNo = errors.New("invalid destination data center")
ErrInvalidDirectClearerCommunicationArea = errors.New("invalid direct clearer communication area")
ErrScanParseError = errors.New("failed to parse txn")
)