diff options
Diffstat (limited to 'adapter')
-rw-r--r-- | adapter/socketclient/socketclient.go | 2 | ||||
-rw-r--r-- | adapter/vpp_api.go | 12 | ||||
-rw-r--r-- | adapter/vppapiclient/vppapiclient.go | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/adapter/socketclient/socketclient.go b/adapter/socketclient/socketclient.go index 043d253..366163f 100644 --- a/adapter/socketclient/socketclient.go +++ b/adapter/socketclient/socketclient.go @@ -419,7 +419,7 @@ func (c *vppClient) GetMsgID(msgName string, msgCrc string) (uint16, error) { msg := msgName + "_" + msgCrc msgID, ok := c.msgTable[msg] if !ok { - return 0, fmt.Errorf("unknown message: %q", msg) + return 0, &adapter.UnknownMsgError{msgName, msgCrc} } return msgID, nil } diff --git a/adapter/vpp_api.go b/adapter/vpp_api.go index 71bf7c2..b32f975 100644 --- a/adapter/vpp_api.go +++ b/adapter/vpp_api.go @@ -16,6 +16,7 @@ package adapter import ( "errors" + "fmt" ) const ( @@ -52,3 +53,14 @@ type VppAPI interface { // WaitReady waits until adapter is ready. WaitReady() error } + +// UnknownMsgError is the error type usually returned by GetMsgID +// method of VppAPI. It describes the name and CRC for the unknown message. +type UnknownMsgError struct { + MsgName string + MsgCrc string +} + +func (u *UnknownMsgError) Error() string { + return fmt.Sprintf("unknown message: %s_%s", u.MsgName, u.MsgCrc) +} diff --git a/adapter/vppapiclient/vppapiclient.go b/adapter/vppapiclient/vppapiclient.go index fcd3f3f..977f32d 100644 --- a/adapter/vppapiclient/vppapiclient.go +++ b/adapter/vppapiclient/vppapiclient.go @@ -116,7 +116,7 @@ func (a *vppClient) GetMsgID(msgName string, msgCrc string) (uint16, error) { msgID := uint16(C.govpp_get_msg_index(nameAndCrc)) if msgID == ^uint16(0) { // VPP does not know this message - return msgID, fmt.Errorf("unknown message: %v (crc: %v)", msgName, msgCrc) + return msgID, &adapter.UnknownMsgError{msgName, msgCrc} } return msgID, nil |