Skip to content

Commit

Permalink
refactor(plc4go): convert some panics to errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed May 10, 2023
1 parent 3011a3e commit 1eaa3d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions plc4go/internal/cbus/MessageCodec.go
Expand Up @@ -234,7 +234,7 @@ lookingForTheEnd:

// Sanity check
if pciResponse && requestToPci {
panic("Invalid state... Can not be response and request at the same time")
return nil, errors.New("Invalid state... Can not be response and request at the same time")
}

// We need to ensure that there is no ! till the first /r
Expand Down Expand Up @@ -271,7 +271,7 @@ lookingForTheEnd:
log.Trace().Msgf("Read packet length %d", packetLength)
read, err := ti.Read(uint32(packetLength))
if err != nil {
panic("Invalid state... If we have peeked that before we should be able to read that now")
return nil, errors.Wrap(err, "Invalid state... If we have peeked that before we should be able to read that now")
}
rawInput = read
}
Expand Down
3 changes: 2 additions & 1 deletion plc4go/spi/transports/pcap/Transport.go
Expand Up @@ -142,7 +142,8 @@ func (m *TransportInstance) Connect() error {
break
}
log.Warn().Err(err).Msg("Error reading")
panic(err)
m.connected = false
return
}
if lastPacketTime != nil && m.speedFactor != 0 {
timeToSleep := captureInfo.Timestamp.Sub(*lastPacketTime)
Expand Down

0 comments on commit 1eaa3d5

Please sign in to comment.