diff --git a/cmd/gouroboros/server.go b/cmd/gouroboros/server.go index 2ca4b5b4..901465b9 100644 --- a/cmd/gouroboros/server.go +++ b/cmd/gouroboros/server.go @@ -43,16 +43,16 @@ func createListenerSocket(f *globalFlags) (net.Listener, error) { switch { case f.socket != "": if err := os.Remove(f.socket); err != nil { - return nil, fmt.Errorf("failed to remove existing socket: %s", err) + return nil, fmt.Errorf("failed to remove existing socket: %w", err) } listen, err = net.Listen("unix", f.socket) if err != nil { - return nil, fmt.Errorf("failed to open listening socket: %s", err) + return nil, fmt.Errorf("failed to open listening socket: %w", err) } case f.address != "": listen, err = net.Listen("tcp", f.address) if err != nil { - return nil, fmt.Errorf("failed to open listening socket: %s", err) + return nil, fmt.Errorf("failed to open listening socket: %w", err) } default: return nil, fmt.Errorf("no listening address or socket specified") diff --git a/connection.go b/connection.go index 25fdbcf1..ca5314ce 100644 --- a/connection.go +++ b/connection.go @@ -282,7 +282,7 @@ func (c *Connection) setupConnection() error { c.errorChan <- io.EOF } else { // Wrap error message to denote it comes from the muxer - c.errorChan <- fmt.Errorf("muxer error: %s", err) + c.errorChan <- fmt.Errorf("muxer error: %w", err) } // Close connection on muxer errors c.Close() @@ -368,7 +368,7 @@ func (c *Connection) setupConnection() error { if !ok { return } - c.errorChan <- fmt.Errorf("protocol error: %s", err) + c.errorChan <- fmt.Errorf("protocol error: %w", err) // Close connection on mini-protocol errors c.Close() } diff --git a/ledger/allegra/allegra.go b/ledger/allegra/allegra.go index ecb62c0c..2438cf50 100644 --- a/ledger/allegra/allegra.go +++ b/ledger/allegra/allegra.go @@ -324,7 +324,7 @@ func (t *AllegraTransaction) Cbor() []byte { func NewAllegraBlockFromCbor(data []byte) (*AllegraBlock, error) { var allegraBlock AllegraBlock if _, err := cbor.Decode(data, &allegraBlock); err != nil { - return nil, fmt.Errorf("Allegra block decode error: %s", err) + return nil, fmt.Errorf("Allegra block decode error: %w", err) } return &allegraBlock, nil } @@ -334,7 +334,7 @@ func NewAllegraTransactionBodyFromCbor( ) (*AllegraTransactionBody, error) { var allegraTx AllegraTransactionBody if _, err := cbor.Decode(data, &allegraTx); err != nil { - return nil, fmt.Errorf("Allegra transaction body decode error: %s", err) + return nil, fmt.Errorf("Allegra transaction body decode error: %w", err) } return &allegraTx, nil } @@ -342,7 +342,7 @@ func NewAllegraTransactionBodyFromCbor( func NewAllegraTransactionFromCbor(data []byte) (*AllegraTransaction, error) { var allegraTx AllegraTransaction if _, err := cbor.Decode(data, &allegraTx); err != nil { - return nil, fmt.Errorf("Allegra transaction decode error: %s", err) + return nil, fmt.Errorf("Allegra transaction decode error: %w", err) } return &allegraTx, nil } diff --git a/ledger/alonzo/alonzo.go b/ledger/alonzo/alonzo.go index ecd51864..00343acc 100644 --- a/ledger/alonzo/alonzo.go +++ b/ledger/alonzo/alonzo.go @@ -527,7 +527,7 @@ func (t *AlonzoTransaction) Utxorpc() *utxorpc.Tx { func NewAlonzoBlockFromCbor(data []byte) (*AlonzoBlock, error) { var alonzoBlock AlonzoBlock if _, err := cbor.Decode(data, &alonzoBlock); err != nil { - return nil, fmt.Errorf("Alonzo block decode error: %s", err) + return nil, fmt.Errorf("Alonzo block decode error: %w", err) } return &alonzoBlock, nil } @@ -537,7 +537,7 @@ func NewAlonzoTransactionBodyFromCbor( ) (*AlonzoTransactionBody, error) { var alonzoTx AlonzoTransactionBody if _, err := cbor.Decode(data, &alonzoTx); err != nil { - return nil, fmt.Errorf("Alonzo transaction body decode error: %s", err) + return nil, fmt.Errorf("Alonzo transaction body decode error: %w", err) } return &alonzoTx, nil } @@ -545,7 +545,7 @@ func NewAlonzoTransactionBodyFromCbor( func NewAlonzoTransactionFromCbor(data []byte) (*AlonzoTransaction, error) { var alonzoTx AlonzoTransaction if _, err := cbor.Decode(data, &alonzoTx); err != nil { - return nil, fmt.Errorf("Alonzo transaction decode error: %s", err) + return nil, fmt.Errorf("Alonzo transaction decode error: %w", err) } return &alonzoTx, nil } @@ -556,7 +556,7 @@ func NewAlonzoTransactionOutputFromCbor( var alonzoTxOutput AlonzoTransactionOutput if _, err := cbor.Decode(data, &alonzoTxOutput); err != nil { return nil, fmt.Errorf( - "Alonzo transaction output decode error: %s", + "Alonzo transaction output decode error: %w", err, ) } diff --git a/ledger/babbage/babbage.go b/ledger/babbage/babbage.go index 61601a67..7cf62c38 100644 --- a/ledger/babbage/babbage.go +++ b/ledger/babbage/babbage.go @@ -681,7 +681,7 @@ func (t *BabbageTransaction) Utxorpc() *utxorpc.Tx { func NewBabbageBlockFromCbor(data []byte) (*BabbageBlock, error) { var babbageBlock BabbageBlock if _, err := cbor.Decode(data, &babbageBlock); err != nil { - return nil, fmt.Errorf("Babbage block decode error: %s", err) + return nil, fmt.Errorf("Babbage block decode error: %w", err) } return &babbageBlock, nil } @@ -689,7 +689,7 @@ func NewBabbageBlockFromCbor(data []byte) (*BabbageBlock, error) { func NewBabbageBlockHeaderFromCbor(data []byte) (*BabbageBlockHeader, error) { var babbageBlockHeader BabbageBlockHeader if _, err := cbor.Decode(data, &babbageBlockHeader); err != nil { - return nil, fmt.Errorf("Babbage block header decode error: %s", err) + return nil, fmt.Errorf("Babbage block header decode error: %w", err) } return &babbageBlockHeader, nil } @@ -699,7 +699,7 @@ func NewBabbageTransactionBodyFromCbor( ) (*BabbageTransactionBody, error) { var babbageTx BabbageTransactionBody if _, err := cbor.Decode(data, &babbageTx); err != nil { - return nil, fmt.Errorf("Babbage transaction body decode error: %s", err) + return nil, fmt.Errorf("Babbage transaction body decode error: %w", err) } return &babbageTx, nil } @@ -707,7 +707,7 @@ func NewBabbageTransactionBodyFromCbor( func NewBabbageTransactionFromCbor(data []byte) (*BabbageTransaction, error) { var babbageTx BabbageTransaction if _, err := cbor.Decode(data, &babbageTx); err != nil { - return nil, fmt.Errorf("Babbage transaction decode error: %s", err) + return nil, fmt.Errorf("Babbage transaction decode error: %w", err) } return &babbageTx, nil } @@ -718,7 +718,7 @@ func NewBabbageTransactionOutputFromCbor( var babbageTxOutput BabbageTransactionOutput if _, err := cbor.Decode(data, &babbageTxOutput); err != nil { return nil, fmt.Errorf( - "Babbage transaction output decode error: %s", + "Babbage transaction output decode error: %w", err, ) } diff --git a/ledger/byron/byron.go b/ledger/byron/byron.go index 8dc39f13..77ca9177 100644 --- a/ledger/byron/byron.go +++ b/ledger/byron/byron.go @@ -689,7 +689,7 @@ func NewByronEpochBoundaryBlockFromCbor( ) (*ByronEpochBoundaryBlock, error) { var byronEbbBlock ByronEpochBoundaryBlock if _, err := cbor.Decode(data, &byronEbbBlock); err != nil { - return nil, fmt.Errorf("Byron EBB block decode error: %s", err) + return nil, fmt.Errorf("Byron EBB block decode error: %w", err) } return &byronEbbBlock, nil } @@ -699,7 +699,7 @@ func NewByronEpochBoundaryBlockHeaderFromCbor( ) (*ByronEpochBoundaryBlockHeader, error) { var byronEbbBlockHeader ByronEpochBoundaryBlockHeader if _, err := cbor.Decode(data, &byronEbbBlockHeader); err != nil { - return nil, fmt.Errorf("Byron EBB block header decode error: %s", err) + return nil, fmt.Errorf("Byron EBB block header decode error: %w", err) } return &byronEbbBlockHeader, nil } @@ -707,7 +707,7 @@ func NewByronEpochBoundaryBlockHeaderFromCbor( func NewByronMainBlockFromCbor(data []byte) (*ByronMainBlock, error) { var byronMainBlock ByronMainBlock if _, err := cbor.Decode(data, &byronMainBlock); err != nil { - return nil, fmt.Errorf("Byron main block decode error: %s", err) + return nil, fmt.Errorf("Byron main block decode error: %w", err) } return &byronMainBlock, nil } @@ -717,7 +717,7 @@ func NewByronMainBlockHeaderFromCbor( ) (*ByronMainBlockHeader, error) { var byronMainBlockHeader ByronMainBlockHeader if _, err := cbor.Decode(data, &byronMainBlockHeader); err != nil { - return nil, fmt.Errorf("Byron main block header decode error: %s", err) + return nil, fmt.Errorf("Byron main block header decode error: %w", err) } return &byronMainBlockHeader, nil } @@ -725,7 +725,7 @@ func NewByronMainBlockHeaderFromCbor( func NewByronTransactionFromCbor(data []byte) (*ByronTransaction, error) { var byronTx ByronTransaction if _, err := cbor.Decode(data, &byronTx); err != nil { - return nil, fmt.Errorf("Byron transaction decode error: %s", err) + return nil, fmt.Errorf("Byron transaction decode error: %w", err) } return &byronTx, nil } diff --git a/ledger/conway/conway.go b/ledger/conway/conway.go index d2d2ac4a..77adf95d 100644 --- a/ledger/conway/conway.go +++ b/ledger/conway/conway.go @@ -472,7 +472,7 @@ func (t *ConwayTransaction) Utxorpc() *utxorpc.Tx { func NewConwayBlockFromCbor(data []byte) (*ConwayBlock, error) { var conwayBlock ConwayBlock if _, err := cbor.Decode(data, &conwayBlock); err != nil { - return nil, fmt.Errorf("Conway block decode error: %s", err) + return nil, fmt.Errorf("Conway block decode error: %w", err) } return &conwayBlock, nil } @@ -480,7 +480,7 @@ func NewConwayBlockFromCbor(data []byte) (*ConwayBlock, error) { func NewConwayBlockHeaderFromCbor(data []byte) (*ConwayBlockHeader, error) { var conwayBlockHeader ConwayBlockHeader if _, err := cbor.Decode(data, &conwayBlockHeader); err != nil { - return nil, fmt.Errorf("Conway block header decode error: %s", err) + return nil, fmt.Errorf("Conway block header decode error: %w", err) } return &conwayBlockHeader, nil } @@ -490,7 +490,7 @@ func NewConwayTransactionBodyFromCbor( ) (*ConwayTransactionBody, error) { var conwayTx ConwayTransactionBody if _, err := cbor.Decode(data, &conwayTx); err != nil { - return nil, fmt.Errorf("Conway transaction body decode error: %s", err) + return nil, fmt.Errorf("Conway transaction body decode error: %w", err) } return &conwayTx, nil } @@ -498,7 +498,7 @@ func NewConwayTransactionBodyFromCbor( func NewConwayTransactionFromCbor(data []byte) (*ConwayTransaction, error) { var conwayTx ConwayTransaction if _, err := cbor.Decode(data, &conwayTx); err != nil { - return nil, fmt.Errorf("Conway transaction decode error: %s", err) + return nil, fmt.Errorf("Conway transaction decode error: %w", err) } return &conwayTx, nil } diff --git a/ledger/error.go b/ledger/error.go index 9f568bd3..3677550e 100644 --- a/ledger/error.go +++ b/ledger/error.go @@ -287,7 +287,7 @@ func (e *UtxoFailure) UnmarshalCBOR(data []byte) error { if err != nil { newErr, err = NewGenericErrorFromCbor(tmpData.Err) if err != nil { - return fmt.Errorf("failed to parse UtxoFailure: %s", err) + return fmt.Errorf("failed to parse UtxoFailure: %w", err) } } e.Err = newErr.(error) diff --git a/ledger/mary/mary.go b/ledger/mary/mary.go index dee70edc..fc63c41e 100644 --- a/ledger/mary/mary.go +++ b/ledger/mary/mary.go @@ -409,7 +409,7 @@ func (v *MaryTransactionOutputValue) MarshalCBOR() ([]byte, error) { func NewMaryBlockFromCbor(data []byte) (*MaryBlock, error) { var maryBlock MaryBlock if _, err := cbor.Decode(data, &maryBlock); err != nil { - return nil, fmt.Errorf("Mary block decode error: %s", err) + return nil, fmt.Errorf("Mary block decode error: %w", err) } return &maryBlock, nil } @@ -417,7 +417,7 @@ func NewMaryBlockFromCbor(data []byte) (*MaryBlock, error) { func NewMaryTransactionBodyFromCbor(data []byte) (*MaryTransactionBody, error) { var maryTx MaryTransactionBody if _, err := cbor.Decode(data, &maryTx); err != nil { - return nil, fmt.Errorf("Mary transaction body decode error: %s", err) + return nil, fmt.Errorf("Mary transaction body decode error: %w", err) } return &maryTx, nil } @@ -425,7 +425,7 @@ func NewMaryTransactionBodyFromCbor(data []byte) (*MaryTransactionBody, error) { func NewMaryTransactionFromCbor(data []byte) (*MaryTransaction, error) { var maryTx MaryTransaction if _, err := cbor.Decode(data, &maryTx); err != nil { - return nil, fmt.Errorf("Mary transaction decode error: %s", err) + return nil, fmt.Errorf("Mary transaction decode error: %w", err) } return &maryTx, nil } @@ -435,7 +435,7 @@ func NewMaryTransactionOutputFromCbor( ) (*MaryTransactionOutput, error) { var maryTxOutput MaryTransactionOutput if _, err := cbor.Decode(data, &maryTxOutput); err != nil { - return nil, fmt.Errorf("Mary transaction output decode error: %s", err) + return nil, fmt.Errorf("Mary transaction output decode error: %w", err) } return &maryTxOutput, nil } diff --git a/ledger/shelley/shelley.go b/ledger/shelley/shelley.go index 5b931eed..8a923700 100644 --- a/ledger/shelley/shelley.go +++ b/ledger/shelley/shelley.go @@ -680,7 +680,7 @@ func (t *ShelleyTransaction) Cbor() []byte { func NewShelleyBlockFromCbor(data []byte) (*ShelleyBlock, error) { var shelleyBlock ShelleyBlock if _, err := cbor.Decode(data, &shelleyBlock); err != nil { - return nil, fmt.Errorf("Shelley block decode error: %s", err) + return nil, fmt.Errorf("Shelley block decode error: %w", err) } return &shelleyBlock, nil } @@ -688,7 +688,7 @@ func NewShelleyBlockFromCbor(data []byte) (*ShelleyBlock, error) { func NewShelleyBlockHeaderFromCbor(data []byte) (*ShelleyBlockHeader, error) { var shelleyBlockHeader ShelleyBlockHeader if _, err := cbor.Decode(data, &shelleyBlockHeader); err != nil { - return nil, fmt.Errorf("Shelley block header decode error: %s", err) + return nil, fmt.Errorf("Shelley block header decode error: %w", err) } return &shelleyBlockHeader, nil } @@ -698,7 +698,7 @@ func NewShelleyTransactionBodyFromCbor( ) (*ShelleyTransactionBody, error) { var shelleyTx ShelleyTransactionBody if _, err := cbor.Decode(data, &shelleyTx); err != nil { - return nil, fmt.Errorf("Shelley transaction body decode error: %s", err) + return nil, fmt.Errorf("Shelley transaction body decode error: %w", err) } return &shelleyTx, nil } @@ -706,7 +706,7 @@ func NewShelleyTransactionBodyFromCbor( func NewShelleyTransactionFromCbor(data []byte) (*ShelleyTransaction, error) { var shelleyTx ShelleyTransaction if _, err := cbor.Decode(data, &shelleyTx); err != nil { - return nil, fmt.Errorf("Shelley transaction decode error: %s", err) + return nil, fmt.Errorf("Shelley transaction decode error: %w", err) } return &shelleyTx, nil } @@ -717,7 +717,7 @@ func NewShelleyTransactionOutputFromCbor( var shelleyTxOutput ShelleyTransactionOutput if _, err := cbor.Decode(data, &shelleyTxOutput); err != nil { return nil, fmt.Errorf( - "Shelley transaction output decode error: %s", + "Shelley transaction output decode error: %w", err, ) } diff --git a/protocol/blockfetch/client.go b/protocol/blockfetch/client.go index 038f7783..b3d2949f 100644 --- a/protocol/blockfetch/client.go +++ b/protocol/blockfetch/client.go @@ -252,7 +252,7 @@ func (c *Client) handleBlock(msgGeneric protocol.Message) error { // Decode only enough to get the block type value var wrappedBlock WrappedBlock if _, err := cbor.Decode(msg.WrappedBlock, &wrappedBlock); err != nil { - return fmt.Errorf("%s: decode error: %s", ProtocolName, err) + return fmt.Errorf("%s: decode error: %w", ProtocolName, err) } var block ledger.Block if !c.blockUseCallback || c.config.BlockFunc != nil { diff --git a/protocol/blockfetch/messages.go b/protocol/blockfetch/messages.go index 51849a97..0866d1fd 100644 --- a/protocol/blockfetch/messages.go +++ b/protocol/blockfetch/messages.go @@ -48,7 +48,7 @@ func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error) { ret = &MsgBatchDone{} } if _, err := cbor.Decode(data, ret); err != nil { - return nil, fmt.Errorf("%s: decode error: %s", ProtocolName, err) + return nil, fmt.Errorf("%s: decode error: %w", ProtocolName, err) } if ret != nil { // Store the raw message CBOR diff --git a/protocol/chainsync/messages.go b/protocol/chainsync/messages.go index 9ca5d34e..7f080431 100644 --- a/protocol/chainsync/messages.go +++ b/protocol/chainsync/messages.go @@ -74,7 +74,7 @@ func NewMsgFromCbor( ret = &MsgDone{} } if _, err := cbor.Decode(data, ret); err != nil { - return nil, fmt.Errorf("%s: decode error: %s", ProtocolName, err) + return nil, fmt.Errorf("%s: decode error: %w", ProtocolName, err) } if ret != nil { // Store the raw message CBOR diff --git a/protocol/handshake/messages.go b/protocol/handshake/messages.go index f822113a..369aae2f 100644 --- a/protocol/handshake/messages.go +++ b/protocol/handshake/messages.go @@ -47,7 +47,7 @@ func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error) { ret = &MsgRefuse{} } if _, err := cbor.Decode(data, ret); err != nil { - return nil, fmt.Errorf("%s: decode error: %s", ProtocolName, err) + return nil, fmt.Errorf("%s: decode error: %w", ProtocolName, err) } if ret != nil { // Store the raw message CBOR diff --git a/protocol/handshake/server.go b/protocol/handshake/server.go index bdcb9483..648500f8 100644 --- a/protocol/handshake/server.go +++ b/protocol/handshake/server.go @@ -161,7 +161,7 @@ func (s *Server) handleProposeVersions(msg protocol.Message) error { return err } return fmt.Errorf( - "handshake failed: refused due to protocol parameters decode failure: %s", + "handshake failed: refused due to protocol parameters decode failure: %w", err, ) } diff --git a/protocol/keepalive/messages.go b/protocol/keepalive/messages.go index 1fddf521..b748bd74 100644 --- a/protocol/keepalive/messages.go +++ b/protocol/keepalive/messages.go @@ -37,7 +37,7 @@ func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error) { ret = &MsgDone{} } if _, err := cbor.Decode(data, ret); err != nil { - return nil, fmt.Errorf("%s: decode error: %s", ProtocolName, err) + return nil, fmt.Errorf("%s: decode error: %w", ProtocolName, err) } if ret != nil { // Store the raw message CBOR diff --git a/protocol/localstatequery/messages.go b/protocol/localstatequery/messages.go index 7252b189..4c83dbf4 100644 --- a/protocol/localstatequery/messages.go +++ b/protocol/localstatequery/messages.go @@ -74,7 +74,7 @@ func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error) { ret = &MsgDone{} } if _, err := cbor.Decode(data, ret); err != nil { - return nil, fmt.Errorf("%s: decode error: %s", ProtocolName, err) + return nil, fmt.Errorf("%s: decode error: %w", ProtocolName, err) } if ret != nil { // Store the raw message CBOR diff --git a/protocol/localtxmonitor/messages.go b/protocol/localtxmonitor/messages.go index 5f7c0eb9..eb61fb3d 100644 --- a/protocol/localtxmonitor/messages.go +++ b/protocol/localtxmonitor/messages.go @@ -62,7 +62,7 @@ func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error) { ret = &MsgReplyGetSizes{} } if _, err := cbor.Decode(data, ret); err != nil { - return nil, fmt.Errorf("%s: decode error: %s", ProtocolName, err) + return nil, fmt.Errorf("%s: decode error: %w", ProtocolName, err) } if ret != nil { // Store the raw message CBOR diff --git a/protocol/localtxsubmission/messages.go b/protocol/localtxsubmission/messages.go index 2bd68164..2ada0641 100644 --- a/protocol/localtxsubmission/messages.go +++ b/protocol/localtxsubmission/messages.go @@ -43,7 +43,7 @@ func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error) { ret = &MsgDone{} } if _, err := cbor.Decode(data, ret); err != nil { - return nil, fmt.Errorf("%s: decode error: %s", ProtocolName, err) + return nil, fmt.Errorf("%s: decode error: %w", ProtocolName, err) } if ret != nil { // Store the raw message CBOR diff --git a/protocol/peersharing/messages.go b/protocol/peersharing/messages.go index 5618681b..27cd0d62 100644 --- a/protocol/peersharing/messages.go +++ b/protocol/peersharing/messages.go @@ -42,7 +42,7 @@ func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error) { ret = &MsgDone{} } if _, err := cbor.Decode(data, ret); err != nil { - return nil, fmt.Errorf("%s: decode error: %s", ProtocolName, err) + return nil, fmt.Errorf("%s: decode error: %w", ProtocolName, err) } if ret != nil { // Store the raw message CBOR diff --git a/protocol/protocol.go b/protocol/protocol.go index 6e81d3ca..948c3331 100644 --- a/protocol/protocol.go +++ b/protocol/protocol.go @@ -262,7 +262,7 @@ func (p *Protocol) sendLoop() { if err := p.transitionState(msg); err != nil { p.SendError( fmt.Errorf( - "%s: error sending message: %s", + "%s: error sending message: %w", p.config.Name, err, ), @@ -368,13 +368,13 @@ func (p *Protocol) recvLoop() { p.recvReadyChan <- true continue } - p.SendError(fmt.Errorf("%s: decode error: %s", p.config.Name, err)) + p.SendError(fmt.Errorf("%s: decode error: %w", p.config.Name, err)) return } // Decode first list item to determine message type var msgType uint if _, err := cbor.Decode(tmpMsg[0], &msgType); err != nil { - p.SendError(fmt.Errorf("%s: decode error: %s", p.config.Name, err)) + p.SendError(fmt.Errorf("%s: decode error: %w", p.config.Name, err)) } // Create Message object from CBOR msgData := recvBuffer.Bytes()[:numBytesRead] @@ -476,7 +476,7 @@ func (p *Protocol) stateLoop(ch <-chan protocolStateTransition) { nextState, err := p.nextState(currentState, t.msg) if err != nil { t.errorChan <- fmt.Errorf( - "%s: error handling protocol state transition: %s", + "%s: error handling protocol state transition: %w", p.config.Name, err, ) @@ -540,7 +540,7 @@ func (p *Protocol) transitionState(msg Message) error { func (p *Protocol) handleMessage(msg Message) error { if err := p.transitionState(msg); err != nil { - return fmt.Errorf("%s: error handling message: %s", p.config.Name, err) + return fmt.Errorf("%s: error handling message: %w", p.config.Name, err) } // Call handler function diff --git a/protocol/txsubmission/messages.go b/protocol/txsubmission/messages.go index 40bb691b..fe42aeac 100644 --- a/protocol/txsubmission/messages.go +++ b/protocol/txsubmission/messages.go @@ -49,7 +49,7 @@ func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error) { ret = &MsgInit{} } if _, err := cbor.Decode(data, ret); err != nil { - return nil, fmt.Errorf("%s: decode error: %s", ProtocolName, err) + return nil, fmt.Errorf("%s: decode error: %w", ProtocolName, err) } if ret != nil { // Store the raw message CBOR