mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Error handling
This commit is contained in:
parent
b851045415
commit
27ad1437a1
8 changed files with 61 additions and 76 deletions
|
@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding;
|
|||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding::BluetoothRemoteGATTDescriptorMethods;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
||||
use dom::bindings::error::Error::Network;
|
||||
use dom::bindings::error::Error::{Type, Network};
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
|
@ -103,10 +103,7 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
|
|||
},
|
||||
BluetoothObjectMsg::Error {
|
||||
error
|
||||
} => {
|
||||
println!("{}", error);
|
||||
None
|
||||
},
|
||||
} => return Err(Type(error)),
|
||||
_ => unreachable!()
|
||||
};
|
||||
*self.value.borrow_mut() = value;
|
||||
|
@ -115,19 +112,17 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
|
|||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-writevalue
|
||||
fn WriteValue(&self, value: Vec<u8>) {
|
||||
fn WriteValue(&self, value: Vec<u8>) -> Fallible<()> {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
self.get_bluetooth_thread().send(
|
||||
BluetoothMethodMsg::WriteValue(self.get_instance_id(), value, sender)).unwrap();
|
||||
let result = receiver.recv().unwrap();
|
||||
match result {
|
||||
BluetoothObjectMsg::BluetoothWriteValue => (),
|
||||
BluetoothObjectMsg::BluetoothWriteValue => Ok(()),
|
||||
BluetoothObjectMsg::Error {
|
||||
error
|
||||
} => {
|
||||
println!("{}", error);
|
||||
},
|
||||
} => Err(Type(error)),
|
||||
_ => unreachable!()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue