Skip to content

Commit

Permalink
fix: ✅ a failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
graugans committed Aug 2, 2024
1 parent ff3c679 commit 2aaddc3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/pcic/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 2aaddc3

Please sign in to comment.