Skip to content
Snippets Groups Projects
Commit dfb8c58c authored by Malte Bauch's avatar Malte Bauch
Browse files

Fix wrong usage of ErrInvalidTypeAssertion

A few calls of ErrInvalidTypeAssertion where not right and resulted in a
meaningless error message output.
parent 2a3dbd8a
No related branches found
No related tags found
1 merge request!251Resolve "Unimplemented methods of PrincipalNetworkDomainAdapter"
......@@ -2,7 +2,6 @@ package nucleus
import (
"path/filepath"
"reflect"
"code.fbi.h-da.de/danet/gosdn/nucleus/errors"
......@@ -249,8 +248,8 @@ func (p *SouthboundPlugin) load(id uuid.UUID) error {
if !ok {
p.state = plugin.FAULTY
return &errors.ErrInvalidTypeAssertion{
Value: reflect.TypeOf(symbol),
Type: reflect.TypeOf((*southbound.SouthboundInterface)(nil)).Elem(),
Value: symbol,
Type: (*southbound.SouthboundInterface)(nil),
}
}
// Note(mbauch): We could consider moving this into plugin creation.
......
......@@ -81,7 +81,7 @@ func (s *DeviceStore) GetDevicesAssociatedWithSbi(sid uuid.UUID) ([]device.Devic
if !ok {
return nil, &errors.ErrInvalidTypeAssertion{
Value: d,
Type: reflect.TypeOf((*device.Device)(nil)),
Type: (*device.Device)(nil),
}
}
// check if the device uses the provided SBI and add it to the devices
......
......@@ -60,8 +60,8 @@ func (s *SbiStore) Add(item store.Storable) error {
_, ok := item.(southbound.SouthboundInterface)
if !ok {
return &errors.ErrInvalidTypeAssertion{
Value: reflect.TypeOf(item),
Type: reflect.TypeOf((*southbound.SouthboundInterface)(nil)).Elem(),
Value: item,
Type: (*southbound.SouthboundInterface)(nil),
}
}
......@@ -96,16 +96,16 @@ func (s *SbiStore) persist() error {
southboundInterface, ok := value.(southbound.SouthboundInterface)
if !ok {
return &errors.ErrInvalidTypeAssertion{
Value: reflect.TypeOf(value),
Type: reflect.TypeOf((*southbound.SouthboundInterface)(nil)).Elem(),
Value: value,
Type: (*southbound.SouthboundInterface)(nil),
}
}
if southboundInterface.Type() == spb.Type_TYPE_CONTAINERISED || southboundInterface.Type() == spb.Type_TYPE_PLUGIN {
southboundPlugin, ok := southboundInterface.(plugin.Plugin)
if !ok {
return &errors.ErrInvalidTypeAssertion{
Value: reflect.TypeOf(southboundInterface),
Type: reflect.TypeOf((*plugin.Plugin)(nil)).Elem(),
Value: southboundInterface,
Type: (*plugin.Plugin)(nil),
}
}
southboundInterfacesToPersist = append(southboundInterfacesToPersist, LoadedSbi{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment