mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* [NOD-1223] Delete unused files/packages. * [NOD-1223] Move signal and limits to the os package. * [NOD-1223] Put database and dbaccess into the db package. * [NOD-1223] Fold the logs package into the logger package. * [NOD-1223] Rename domainmessage to appmessage. * [NOD-1223] Rename to/from DomainMessage to AppMessage. * [NOD-1223] Move appmessage to the app packge. * [NOD-1223] Move protocol to the app packge. * [NOD-1223] Move the network package to the infrastructure packge. * [NOD-1223] Rename cmd to executables. * [NOD-1223] Fix go.doc in the logger package.
32 lines
809 B
Go
32 lines
809 B
Go
package flowcontext
|
|
|
|
import (
|
|
"errors"
|
|
"sync/atomic"
|
|
|
|
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
|
|
|
|
"github.com/kaspanet/kaspad/app/protocol/protocolerrors"
|
|
)
|
|
|
|
// HandleError handles an error from a flow,
|
|
// It sends the error to errChan if isStopping == 0 and increments isStopping
|
|
//
|
|
// If this is ErrRouteClosed - ignores the error
|
|
// If this is ProtocolError - logs the error
|
|
// Otherwise - panics
|
|
func (*FlowContext) HandleError(err error, flowName string, isStopping *uint32, errChan chan<- error) {
|
|
if errors.Is(err, router.ErrRouteClosed) {
|
|
return
|
|
}
|
|
|
|
if protocolErr := &(protocolerrors.ProtocolError{}); !errors.As(err, &protocolErr) {
|
|
panic(err)
|
|
}
|
|
|
|
log.Errorf("error from %s: %+v", flowName, err)
|
|
if atomic.AddUint32(isStopping, 1) == 1 {
|
|
errChan <- err
|
|
}
|
|
}
|