@@ -707,6 +707,10 @@ type OrderHandlerCfg struct {
707707 // that is encapsulated in the init and reestablish peer messages. This
708708 // helps us communicate custom feature bits with our peer.
709709 AuxChanNegotiator * tapfeatures.AuxChannelNegotiator
710+
711+ // ErrChan is the main error channel that is used to propagate critical
712+ // errors back to the parent manager/server.
713+ ErrChan chan <- error
710714}
711715
712716// OrderHandler orchestrates management of accepted quote bundles. It monitors
@@ -928,8 +932,16 @@ func (h *OrderHandler) Start() error {
928932
929933 startErr = h .setupHtlcIntercept (ctx )
930934 if startErr != nil {
931- log .Errorf ("Error setting up HTLC " +
932- "interception: %v" , startErr )
935+ startErr = fmt .Errorf ("setting up HTLC " +
936+ "interception: %w" , startErr )
937+
938+ // Failing to start HTLC interception is a
939+ // critical error for the order handler, so we
940+ // propagate it upward.
941+ h .ReportMainChanError (
942+ fn .NewCriticalError (startErr ),
943+ )
944+
933945 return
934946 }
935947
@@ -954,6 +966,21 @@ func (h *OrderHandler) Start() error {
954966 return startErr
955967}
956968
969+ // ReportMainChanError sends an error to the main error channel.
970+ func (h * OrderHandler ) ReportMainChanError (err error ) {
971+ select {
972+ // Send the error to the main error channel.
973+ case h .cfg .ErrChan <- err :
974+
975+ // The service is shutting down, so we'll just return.
976+ case <- h .Quit :
977+
978+ // Otherwise, if the error channel is full, we drop the error to avoid
979+ // blocking.
980+ default :
981+ }
982+ }
983+
957984// RegisterAssetSalePolicy generates and registers an asset sale policy with the
958985// order handler. This function takes an outgoing buy accept message as an
959986// argument.
0 commit comments