Prevent BLE HR monitor process crash (fixes: #135)
In case of an uncaught exception in the BLE HR child process the process would crash and not restart. Add code to catch these uncaught exceptions to prevent such crash and enable code to continue.
This commit is contained in:
parent
c5bec08ea9
commit
ee667d727a
|
|
@ -11,7 +11,15 @@ import config from '../../../tools/ConfigManager.js'
|
|||
import { createHeartRateManager } from './HeartRateManager.js'
|
||||
|
||||
log.setLevel(config.loglevel.default)
|
||||
const heartRateManager = createHeartRateManager()
|
||||
heartRateManager.on('heartRateMeasurement', (heartRateMeasurement) => {
|
||||
process.send(heartRateMeasurement)
|
||||
})
|
||||
start()
|
||||
|
||||
function start () {
|
||||
const heartRateManager = createHeartRateManager()
|
||||
heartRateManager.on('heartRateMeasurement', (heartRateMeasurement) => {
|
||||
process.send(heartRateMeasurement)
|
||||
})
|
||||
|
||||
process.on('uncaughtException', (err) => {
|
||||
log.error('An error occurred in BLE Heart Rate service if you experience issues with the bluetooth connection to your heart rate sensor please restart app: ', err)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue