forked from shopspring/decimal
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patherrors.go
40 lines (32 loc) · 1018 Bytes
/
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
package decimal
import "fmt"
// ErrorExponentLimit is returned when the decimal exponent exceed int32 range.
type ErrorExponentLimit struct {
value string
}
// Error implements error interface.
func (e *ErrorExponentLimit) Error() string {
return fmt.Sprintf("can't convert %s to decimal: fractional part too long", e.value)
}
// ErrorInvalidFormat is returned when the input string is not valid integer.
type ErrorInvalidFormat struct {
reason string
}
// Error implements error interface.
func (e *ErrorInvalidFormat) Error() string {
return e.reason
}
// ErrorInvalidType is returned when the value passed into sql.Scanner is not
// with expected type. (valid types: int64, float64, []byte, string)
type ErrorInvalidType struct {
reason string
}
// Error implements error interface.
func (e *ErrorInvalidType) Error() string {
return e.reason
}
func assertErrorInterface() {
var _ error = (*ErrorExponentLimit)(nil)
var _ error = (*ErrorInvalidFormat)(nil)
var _ error = (*ErrorInvalidType)(nil)
}