Unhandled Exception in Ant.GenericChannel.close

I see some Unhandled Exceptions in ERAViewer:

Error Name: Unhandled Exception
Occurrences: 7
First Occurrence: 2023-11-12
Last Occurrence: 2023-11-12
Devices:
Forerunner® 265: 16.17
App Versions: 2.3.1
Languages: eng
Backtrace:
 MySensor.setAntId:55

The code is:

class MySensor extends Ant.GenericChannel {
    public function setAntId(antId as Number) as Void {
        if (antId != deviceCfg.deviceNumber) {
            close(); // this is line 55
            open();
        }
    }

}

Any idea what can cause it? How should I fix this?