Added try catch block

This commit is contained in:
hiar
2025-08-08 15:07:20 +02:00
committed by Himali Aryal
parent aad8d66670
commit cb7c081413

View File

@@ -181,10 +181,10 @@ internal class ProfileService : NotificationService() {
}
private suspend fun connectPeripheral(peripheral: Peripheral) {
runCatching {
try {
centralManager.connect(peripheral, options = ConnectionOptions.Direct())
}.onFailure { exception ->
Timber.e(exception, "Could not connect to the ${peripheral.address}")
} catch (e: Exception) {
Timber.e(e, "Failed to connect to the ${peripheral.address}")
stopForegroundService() // Stop service if connection fails
}
}