mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Return with NotFoundError insted of TypeError, when adapter is not found.
This commit is contained in:
parent
4ed461c6e5
commit
98f2233f2d
3 changed files with 4 additions and 16 deletions
|
@ -31,10 +31,6 @@ use std::thread;
|
|||
use std::time::Duration;
|
||||
use util::thread::spawn_named;
|
||||
|
||||
const ADAPTER_ERROR: &'static str = "No adapter found";
|
||||
|
||||
const ADAPTER_NOT_POWERED_ERROR: &'static str = "Bluetooth adapter not powered";
|
||||
|
||||
// A transaction not completed within 30 seconds shall time out. Such a transaction shall be considered to have failed.
|
||||
// https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=286439 (Vol. 3, page 480)
|
||||
const MAXIMUM_TRANSACTION_TIME: u8 = 30;
|
||||
|
@ -75,11 +71,11 @@ macro_rules! get_adapter_or_return_error(
|
|||
match $bl_manager.get_or_create_adapter() {
|
||||
Some(adapter) => {
|
||||
if !adapter.is_powered().unwrap_or(false) {
|
||||
return drop($sender.send(Err(BluetoothError::Type(ADAPTER_NOT_POWERED_ERROR.to_string()))))
|
||||
return drop($sender.send(Err(BluetoothError::NotFound)))
|
||||
}
|
||||
adapter
|
||||
},
|
||||
None => return drop($sender.send(Err(BluetoothError::Type(ADAPTER_ERROR.to_string())))),
|
||||
None => return drop($sender.send(Err(BluetoothError::NotFound))),
|
||||
}
|
||||
);
|
||||
);
|
||||
|
@ -701,7 +697,7 @@ impl BluetoothManager {
|
|||
}
|
||||
let mut adapter = match self.get_or_create_adapter() {
|
||||
Some(a) => a,
|
||||
None => return drop(sender.send(Err(BluetoothError::Type(ADAPTER_ERROR.to_string())))),
|
||||
None => return drop(sender.send(Err(BluetoothError::NotFound))),
|
||||
};
|
||||
let device = match self.device_from_service_id(&service_id) {
|
||||
Some(device) => device,
|
||||
|
@ -735,7 +731,7 @@ impl BluetoothManager {
|
|||
}
|
||||
let mut adapter = match self.get_or_create_adapter() {
|
||||
Some(a) => a,
|
||||
None => return drop(sender.send(Err(BluetoothError::Type(ADAPTER_ERROR.to_string())))),
|
||||
None => return drop(sender.send(Err(BluetoothError::NotFound))),
|
||||
};
|
||||
let device = match self.device_from_service_id(&service_id) {
|
||||
Some(device) => device,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue