Error handling

This commit is contained in:
zakorgy 2016-04-06 16:31:29 +02:00 committed by Attila Dusnoki
parent b851045415
commit 27ad1437a1
8 changed files with 61 additions and 76 deletions

View file

@ -188,10 +188,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
},
BluetoothObjectMsg::Error {
error
} => {
println!("{}", error);
None
},
} => return Err(Type(error)),
_ => unreachable!()
};
*self.value.borrow_mut() = value;
@ -200,19 +197,17 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-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!()
};
}
}
}