From 2aaddc32c6dba82370b0cfe171b61b0935b62b43 Mon Sep 17 00:00:00 2001 From: Christian Ege Date: Fri, 2 Aug 2024 06:23:06 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E2=9C=85=20a=20failing=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/pcic/protocol.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/pcic/protocol.go b/pkg/pcic/protocol.go index 7e10687..6205b5c 100644 --- a/pkg/pcic/protocol.go +++ b/pkg/pcic/protocol.go @@ -189,7 +189,7 @@ func (p *PCICClient) ProcessIncomming(handler MessageHandler) error { handler.Result(frame) return err } else if bytes.Equal(errorTicket, firstTicket) { - errorStatus, err := p.errorParser(string(data)) + errorStatus, err := p.errorParser(string(data[:len(data)-2])) handler.Error(errorStatus) return err } @@ -292,6 +292,9 @@ func (p *PCICClient) errorParser(data string) (ErrorMessage, error) { errorStatus.ID, err = strconv.Atoi(idStr) if len(matches) == 3 { errorStatus.Message = matches[2] + if len(errorStatus.Message) == 0 { + return errorStatus, fmt.Errorf("a malformed error message was received: %s", data) + } } return errorStatus, err }