diff options
| author | Kali Kaneko (leap communications) <kali@leap.se> | 2018-12-13 19:45:48 +0100 | 
|---|---|---|
| committer | Kali Kaneko (leap communications) <kali@leap.se> | 2018-12-13 19:47:11 +0100 | 
| commit | 81843a0477c5eba4b3d4f6ff932f748f9e1244e7 (patch) | |
| tree | 6068ae0ff1d8ac617e2781fb8aa68200e71403f2 /vendor/github.com/oschwald/maxminddb-golang/errors.go | |
| parent | ac56a90e21118dc1ddfc1bd5e69d87f157710412 (diff) | |
vendor packages
Diffstat (limited to 'vendor/github.com/oschwald/maxminddb-golang/errors.go')
| -rw-r--r-- | vendor/github.com/oschwald/maxminddb-golang/errors.go | 42 | 
1 files changed, 42 insertions, 0 deletions
| diff --git a/vendor/github.com/oschwald/maxminddb-golang/errors.go b/vendor/github.com/oschwald/maxminddb-golang/errors.go new file mode 100644 index 0000000..1327800 --- /dev/null +++ b/vendor/github.com/oschwald/maxminddb-golang/errors.go @@ -0,0 +1,42 @@ +package maxminddb + +import ( +	"fmt" +	"reflect" +) + +// InvalidDatabaseError is returned when the database contains invalid data +// and cannot be parsed. +type InvalidDatabaseError struct { +	message string +} + +func newOffsetError() InvalidDatabaseError { +	return InvalidDatabaseError{"unexpected end of database"} +} + +func newInvalidDatabaseError(format string, args ...interface{}) InvalidDatabaseError { +	return InvalidDatabaseError{fmt.Sprintf(format, args...)} +} + +func (e InvalidDatabaseError) Error() string { +	return e.message +} + +// UnmarshalTypeError is returned when the value in the database cannot be +// assigned to the specified data type. +type UnmarshalTypeError struct { +	Value string       // stringified copy of the database value that caused the error +	Type  reflect.Type // type of the value that could not be assign to +} + +func newUnmarshalTypeError(value interface{}, rType reflect.Type) UnmarshalTypeError { +	return UnmarshalTypeError{ +		Value: fmt.Sprintf("%v", value), +		Type:  rType, +	} +} + +func (e UnmarshalTypeError) Error() string { +	return fmt.Sprintf("maxminddb: cannot unmarshal %s into type %s", e.Value, e.Type.String()) +} | 
