diff --git a/iproute2/base.go b/iproute2/base.go index 4d9885f..5ee73ec 100644 --- a/iproute2/base.go +++ b/iproute2/base.go @@ -214,7 +214,7 @@ func unmarshalInterfacesData(data string) (Interfaces, error) { var addresses Interfaces err := json.Unmarshal([]byte(data), &addresses) if err != nil { - return nil, err + return nil, &UnmarshalError{Msg: err.Error(), Content: data} } return addresses, nil diff --git a/iproute2/error.go b/iproute2/error.go index 87ea93e..2e89bb3 100644 --- a/iproute2/error.go +++ b/iproute2/error.go @@ -42,6 +42,15 @@ func (e *OperationNotPermittedError) Error() string { return e.Msg } +type UnmarshalError struct { + Msg string + Content string +} + +func (e *UnmarshalError) Error() string { + return fmt.Sprint(e.Msg, ": ", e.Content) +} + type UnknownError struct { Msg string }