From 46a9e1308b673325580313ce52c885333afd9c04 Mon Sep 17 00:00:00 2001 From: Arkadiusz Osowski Date: Mon, 9 Dec 2024 08:29:31 +0100 Subject: [PATCH] feat: add typed error ErrUnhandledCmdReceived --- wire/message.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wire/message.go b/wire/message.go index 6b79c25..0378e97 100644 --- a/wire/message.go +++ b/wire/message.go @@ -110,6 +110,8 @@ type Message interface { MaxPayloadLength(uint32) uint64 } +var ErrUnhandledCmdReceived = errors.New("unhandled command") + // makeEmptyMessage creates a message of the appropriate concrete type based // on the command. func makeEmptyMessage(command string) (Message, error) { @@ -218,7 +220,7 @@ func makeEmptyMessage(command string) (Message, error) { msg = &MsgSendcmpct{} default: - return nil, fmt.Errorf("unhandled command [%s]: %#v", command, msg) + return nil, fmt.Errorf("%w [%s]", ErrUnhandledCmdReceived, command) } return msg, nil }