1
|
|
|
package errs |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
"errors" |
5
|
|
|
"fmt" |
6
|
|
|
) |
7
|
|
|
|
8
|
|
|
var ( |
9
|
|
|
ErrUnsupportedType = errors.New("unsupported type.") |
10
|
|
|
ErrEmptyString = errors.New("the given string is empty.") |
11
|
|
|
ErrNilReference = errors.New("the given parameter is nil.") |
12
|
|
|
ErrOutOfRange = errors.New("converter: out of range.") |
13
|
|
|
) |
14
|
|
|
|
15
|
|
|
func NewUnsupportedTypeError(kind string) error { |
16
|
|
|
return fmt.Errorf("the given parameter(%s) is unsupported type ", kind) |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
func NilReferenceTypeError() error { |
20
|
|
|
return fmt.Errorf("the given parameter is nil ") |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
func EmptyStringError() error { |
24
|
|
|
return fmt.Errorf("the given string is empty") |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
func Int64Error(kind string) error { |
28
|
|
|
return fmt.Errorf("the entered value cannot convert from %s to int64", kind) |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
func Int32Error(kind string) error { |
32
|
|
|
return fmt.Errorf("the entered value cannot convert from %s to int32", kind) |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
func Int16Error(kind string) error { |
36
|
|
|
return fmt.Errorf("the entered value cannot convert from %s to int16", kind) |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
func CustomError(message string) error { |
40
|
|
|
return fmt.Errorf(message) |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
func NewUnsupportedParameterTypeError(kind string, desc string) error { |
44
|
|
|
return fmt.Errorf("the given parameter/s(%s) is unsupported type. %s", kind, desc) |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
func NewMissingParameterError(kind string, desc string) error { |
48
|
|
|
return fmt.Errorf("the given parameter/s(%s) is missing. %s", kind, desc) |
49
|
|
|
} |
50
|
|
|
|