Skip to content

Commit 2e013c0

Browse files
authored
Throw BluetoothDisabledException instead of IllegalStateException on scan (#323)
* Use a BluetoothDisabledException on Android when a bluetoothScanner returns null, instead of a IllegalStateException
1 parent b2f4954 commit 2e013c0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

core/src/androidMain/kotlin/Scanner.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class AndroidScanner internal constructor(
3535
?: error("Bluetooth not supported")
3636

3737
public override val advertisements: Flow<Advertisement> = callbackFlow {
38-
val scanner = checkNotNull(bluetoothAdapter.bluetoothLeScanner) { "Bluetooth disabled." }
38+
val scanner = bluetoothAdapter.bluetoothLeScanner ?: throw BluetoothDisabledException()
3939

4040
val callback = object : ScanCallback() {
4141
override fun onScanResult(callbackType: Int, result: ScanResult) {

0 commit comments

Comments
 (0)