|
1 | 1 | package maxminddb |
2 | 2 |
|
3 | | -import ( |
4 | | - "fmt" |
5 | | - "reflect" |
6 | | -) |
7 | | - |
8 | | -// InvalidDatabaseError is returned when the database contains invalid data |
9 | | -// and cannot be parsed. |
10 | | -type InvalidDatabaseError struct { |
11 | | - message string |
12 | | -} |
13 | | - |
14 | | -func newOffsetError() InvalidDatabaseError { |
15 | | - return InvalidDatabaseError{"unexpected end of database"} |
16 | | -} |
17 | | - |
18 | | -func newInvalidDatabaseError(format string, args ...any) InvalidDatabaseError { |
19 | | - return InvalidDatabaseError{fmt.Sprintf(format, args...)} |
20 | | -} |
| 3 | +import "github.com/oschwald/maxminddb-golang/v2/internal/mmdberrors" |
21 | 4 |
|
22 | | -func (e InvalidDatabaseError) Error() string { |
23 | | - return e.message |
24 | | -} |
| 5 | +type ( |
| 6 | + // InvalidDatabaseError is returned when the database contains invalid data |
| 7 | + // and cannot be parsed. |
| 8 | + InvalidDatabaseError = mmdberrors.InvalidDatabaseError |
25 | 9 |
|
26 | | -// UnmarshalTypeError is returned when the value in the database cannot be |
27 | | -// assigned to the specified data type. |
28 | | -type UnmarshalTypeError struct { |
29 | | - Type reflect.Type |
30 | | - Value string |
31 | | -} |
32 | | - |
33 | | -func newUnmarshalTypeStrError(value string, rType reflect.Type) UnmarshalTypeError { |
34 | | - return UnmarshalTypeError{ |
35 | | - Type: rType, |
36 | | - Value: value, |
37 | | - } |
38 | | -} |
39 | | - |
40 | | -func newUnmarshalTypeError(value any, rType reflect.Type) UnmarshalTypeError { |
41 | | - return newUnmarshalTypeStrError(fmt.Sprintf("%v (%T)", value, value), rType) |
42 | | -} |
43 | | - |
44 | | -func (e UnmarshalTypeError) Error() string { |
45 | | - return fmt.Sprintf("maxminddb: cannot unmarshal %s into type %s", e.Value, e.Type) |
46 | | -} |
| 10 | + // UnmarshalTypeError is returned when the value in the database cannot be |
| 11 | + // assigned to the specified data type. |
| 12 | + UnmarshalTypeError = mmdberrors.UnmarshalTypeError |
| 13 | +) |
0 commit comments