diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-07-28 03:33:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-28 03:33:08 -0500 |
commit | 45209b7ffea7b2355e227719ed29cb6aa6f00e0f (patch) | |
tree | 8a7932d98d3763650cb977b380d1bbbe702c13d7 | |
parent | a0c502261dc2bd710e31dcbbbd2d81d2a2c53724 (diff) | |
parent | b4db14471bb6273e681a7f4945a4f8d0d9a6c8ea (diff) | |
download | servo-45209b7ffea7b2355e227719ed29cb6aa6f00e0f.tar.gz servo-45209b7ffea7b2355e227719ed29cb6aa6f00e0f.zip |
Auto merge of #12538 - szeged:error-refactor, r=nox
Refactor Bluetooth error handling
<!-- Please describe your changes on the following line: -->
Replace the error messages with an enum in `net/bluetooth_thread.rs`. Rename `bluetooth_blacklist.rs` to `bluetooth_utils.rs` and put the error conversion in it.
With this the returned errors in DOM classes follow the specification.
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because there is no Web Bluetooth test API implementation yet.
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12538)
<!-- Reviewable:end -->
-rw-r--r-- | components/net/bluetooth_thread.rs | 72 | ||||
-rw-r--r-- | components/net_traits/bluetooth_thread.rs | 12 | ||||
-rw-r--r-- | components/script/dom/bluetooth.rs | 18 | ||||
-rw-r--r-- | components/script/dom/bluetoothremotegattcharacteristic.rs | 10 | ||||
-rw-r--r-- | components/script/dom/bluetoothremotegattdescriptor.rs | 6 | ||||
-rw-r--r-- | components/script/dom/bluetoothremotegattserver.rs | 10 | ||||
-rw-r--r-- | components/script/dom/bluetoothremotegattservice.rs | 10 |
7 files changed, 76 insertions, 62 deletions
diff --git a/components/net/bluetooth_thread.rs b/components/net/bluetooth_thread.rs index 1b882763911..3c2538b1f88 100644 --- a/components/net/bluetooth_thread.rs +++ b/components/net/bluetooth_thread.rs @@ -12,7 +12,7 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use net_traits::bluetooth_scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence, RequestDeviceoptions}; use net_traits::bluetooth_thread::{BluetoothCharacteristicMsg, BluetoothCharacteristicsMsg}; use net_traits::bluetooth_thread::{BluetoothDescriptorMsg, BluetoothDescriptorsMsg}; -use net_traits::bluetooth_thread::{BluetoothDeviceMsg, BluetoothMethodMsg}; +use net_traits::bluetooth_thread::{BluetoothDeviceMsg, BluetoothError, BluetoothMethodMsg}; use net_traits::bluetooth_thread::{BluetoothResult, BluetoothServiceMsg, BluetoothServicesMsg}; use rand::{self, Rng}; use std::borrow::ToOwned; @@ -25,15 +25,7 @@ use tinyfiledialogs; use util::thread::spawn_named; const ADAPTER_ERROR: &'static str = "No adapter found"; -const DEVICE_ERROR: &'static str = "No device found"; -const DEVICE_MATCH_ERROR: &'static str = "No device found, that matches the given options"; -const PRIMARY_SERVICE_ERROR: &'static str = "No primary service found"; -const INCLUDED_SERVICE_ERROR: &'static str = "No included service found"; -const CHARACTERISTIC_ERROR: &'static str = "No characteristic found"; -const DESCRIPTOR_ERROR: &'static str = "No descriptor found"; -const VALUE_ERROR: &'static str = "No characteristic or descriptor found with that id"; -const SECURITY_ERROR: &'static str = "The operation is insecure"; -const NETWORK_ERROR: &'static str = "A network error occurred"; + // 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; @@ -73,7 +65,7 @@ macro_rules! get_adapter_or_return_error( ($bl_manager:expr, $sender:expr) => ( match $bl_manager.get_or_create_adapter() { Some(adapter) => adapter, - None => return drop($sender.send(Err(String::from(ADAPTER_ERROR)))), + None => return drop($sender.send(Err(BluetoothError::Type(ADAPTER_ERROR.to_string())))), } ); ); @@ -453,7 +445,7 @@ impl BluetoothManager { if let Some(address) = self.select_device(matched_devices) { let device_id = match self.address_to_id.get(&address) { Some(id) => id.clone(), - None => return drop(sender.send(Err(String::from(DEVICE_MATCH_ERROR)))), + None => return drop(sender.send(Err(BluetoothError::NotFound))), }; let mut services = options.get_services_set(); if let Some(services_set) = self.allowed_services.get(&device_id) { @@ -471,7 +463,7 @@ impl BluetoothManager { return drop(sender.send(message)); } } - return drop(sender.send(Err(String::from(DEVICE_MATCH_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } fn gatt_server_connect(&mut self, device_id: String, sender: IpcSender<BluetoothResult<bool>>) { @@ -489,9 +481,9 @@ impl BluetoothManager { false => thread::sleep(Duration::from_millis(CONNECTION_TIMEOUT_MS)), } } - return drop(sender.send(Err(String::from(NETWORK_ERROR)))); + return drop(sender.send(Err(BluetoothError::Network))); }, - None => return drop(sender.send(Err(String::from(DEVICE_ERROR)))), + None => return drop(sender.send(Err(BluetoothError::NotFound))), } } @@ -510,9 +502,9 @@ impl BluetoothManager { false => return drop(sender.send(Ok(false))), } } - return drop(sender.send(Err(String::from(NETWORK_ERROR)))); + return drop(sender.send(Err(BluetoothError::Network))); }, - None => return drop(sender.send(Err(String::from(DEVICE_ERROR)))), + None => return drop(sender.send(Err(BluetoothError::NotFound))), } } @@ -522,11 +514,11 @@ impl BluetoothManager { sender: IpcSender<BluetoothResult<BluetoothServiceMsg>>) { let mut adapter = get_adapter_or_return_error!(self, sender); if !self.allowed_services.get(&device_id).map_or(false, |s| s.contains(&uuid)) { - return drop(sender.send(Err(String::from(SECURITY_ERROR)))); + return drop(sender.send(Err(BluetoothError::Security))); } let services = self.get_gatt_services_by_uuid(&mut adapter, &device_id, &uuid); if services.is_empty() { - return drop(sender.send(Err(String::from(PRIMARY_SERVICE_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } for service in services { if service.is_primary().unwrap_or(false) { @@ -539,7 +531,7 @@ impl BluetoothManager { } } } - return drop(sender.send(Err(String::from(PRIMARY_SERVICE_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } fn get_primary_services(&mut self, @@ -550,14 +542,14 @@ impl BluetoothManager { let services = match uuid { Some(ref id) => { if !self.allowed_services.get(&device_id).map_or(false, |s| s.contains(id)) { - return drop(sender.send(Err(String::from(SECURITY_ERROR)))) + return drop(sender.send(Err(BluetoothError::Security))) } self.get_gatt_services_by_uuid(&mut adapter, &device_id, id) }, None => self.get_and_cache_gatt_services(&mut adapter, &device_id), }; if services.is_empty() { - return drop(sender.send(Err(String::from(PRIMARY_SERVICE_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } let mut services_vec = vec!(); for service in services { @@ -572,7 +564,7 @@ impl BluetoothManager { } } if services_vec.is_empty() { - return drop(sender.send(Err(String::from(PRIMARY_SERVICE_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } let _ = sender.send(Ok(services_vec)); @@ -584,11 +576,11 @@ impl BluetoothManager { sender: IpcSender<BluetoothResult<BluetoothServiceMsg>>) { let mut adapter = match self.get_or_create_adapter() { Some(a) => a, - None => return drop(sender.send(Err(String::from(ADAPTER_ERROR)))), + None => return drop(sender.send(Err(BluetoothError::Type(ADAPTER_ERROR.to_string())))), }; let primary_service = match self.get_gatt_service(&mut adapter, &service_id) { Some(s) => s, - None => return drop(sender.send(Err(String::from(PRIMARY_SERVICE_ERROR)))), + None => return drop(sender.send(Err(BluetoothError::NotFound))), }; let services = primary_service.get_includes().unwrap_or(vec!()); for service in services { @@ -602,7 +594,7 @@ impl BluetoothManager { } } } - return drop(sender.send(Err(String::from(INCLUDED_SERVICE_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } fn get_included_services(&mut self, @@ -611,11 +603,11 @@ impl BluetoothManager { sender: IpcSender<BluetoothResult<BluetoothServicesMsg>>) { let mut adapter = match self.get_or_create_adapter() { Some(a) => a, - None => return drop(sender.send(Err(String::from(ADAPTER_ERROR)))), + None => return drop(sender.send(Err(BluetoothError::Type(ADAPTER_ERROR.to_string())))), }; let primary_service = match self.get_gatt_service(&mut adapter, &service_id) { Some(s) => s, - None => return drop(sender.send(Err(String::from(PRIMARY_SERVICE_ERROR)))), + None => return drop(sender.send(Err(BluetoothError::NotFound))), }; let services = primary_service.get_includes().unwrap_or(vec!()); let mut services_vec = vec!(); @@ -632,7 +624,7 @@ impl BluetoothManager { services_vec.retain(|ref s| s.uuid == uuid); } if services_vec.is_empty() { - return drop(sender.send(Err(String::from(INCLUDED_SERVICE_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } let _ = sender.send(Ok(services_vec)); @@ -645,7 +637,7 @@ impl BluetoothManager { let mut adapter = get_adapter_or_return_error!(self, sender); let characteristics = self.get_gatt_characteristics_by_uuid(&mut adapter, &service_id, &uuid); if characteristics.is_empty() { - return drop(sender.send(Err(String::from(CHARACTERISTIC_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } for characteristic in characteristics { if let Ok(uuid) = characteristic.get_uuid() { @@ -666,7 +658,7 @@ impl BluetoothManager { return drop(sender.send(message)); } } - return drop(sender.send(Err(String::from(CHARACTERISTIC_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } fn get_characteristics(&mut self, @@ -679,7 +671,7 @@ impl BluetoothManager { None => self.get_and_cache_gatt_characteristics(&mut adapter, &service_id), }; if characteristics.is_empty() { - return drop(sender.send(Err(String::from(CHARACTERISTIC_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } let mut characteristics_vec = vec!(); for characteristic in characteristics { @@ -702,7 +694,7 @@ impl BluetoothManager { } } if characteristics_vec.is_empty() { - return drop(sender.send(Err(String::from(CHARACTERISTIC_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } let _ = sender.send(Ok(characteristics_vec)); @@ -715,7 +707,7 @@ impl BluetoothManager { let mut adapter = get_adapter_or_return_error!(self, sender); let descriptors = self.get_gatt_descriptors_by_uuid(&mut adapter, &characteristic_id, &uuid); if descriptors.is_empty() { - return drop(sender.send(Err(String::from(DESCRIPTOR_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } for descriptor in descriptors { if let Ok(uuid) = descriptor.get_uuid() { @@ -725,7 +717,7 @@ impl BluetoothManager { }))); } } - return drop(sender.send(Err(String::from(DESCRIPTOR_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } fn get_descriptors(&mut self, @@ -738,7 +730,7 @@ impl BluetoothManager { None => self.get_and_cache_gatt_descriptors(&mut adapter, &characteristic_id), }; if descriptors.is_empty() { - return drop(sender.send(Err(String::from(DESCRIPTOR_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } let mut descriptors_vec = vec!(); for descriptor in descriptors { @@ -750,7 +742,7 @@ impl BluetoothManager { } } if descriptors_vec.is_empty() { - return drop(sender.send(Err(String::from(DESCRIPTOR_ERROR)))); + return drop(sender.send(Err(BluetoothError::NotFound))); } let _ = sender.send(Ok(descriptors_vec)); } @@ -763,7 +755,7 @@ impl BluetoothManager { value = self.get_gatt_descriptor(&mut adapter, &id) .map(|d| d.read_value().unwrap_or(vec![])); } - let _ = sender.send(value.ok_or(String::from(VALUE_ERROR))); + let _ = sender.send(value.ok_or(BluetoothError::NotSupported)); } fn write_value(&mut self, id: String, value: Vec<u8>, sender: IpcSender<BluetoothResult<bool>>) { @@ -777,9 +769,9 @@ impl BluetoothManager { let message = match result { Some(v) => match v { Ok(_) => Ok(true), - Err(e) => return drop(sender.send(Err(e.to_string()))), + Err(_) => return drop(sender.send(Err(BluetoothError::NotSupported))), }, - None => return drop(sender.send(Err(String::from(VALUE_ERROR)))), + None => return drop(sender.send(Err(BluetoothError::NotSupported))), }; let _ = sender.send(message); } diff --git a/components/net_traits/bluetooth_thread.rs b/components/net_traits/bluetooth_thread.rs index caeadabd6d4..48f64ff7474 100644 --- a/components/net_traits/bluetooth_thread.rs +++ b/components/net_traits/bluetooth_thread.rs @@ -1,10 +1,20 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + use bluetooth_scanfilter::RequestDeviceoptions; use ipc_channel::ipc::IpcSender; #[derive(Deserialize, Serialize)] +pub enum BluetoothError { + Type(String), + Network, + NotFound, + NotSupported, + Security, +} + +#[derive(Deserialize, Serialize)] pub struct BluetoothDeviceMsg { // Bluetooth Device properties pub id: String, @@ -51,7 +61,7 @@ pub type BluetoothCharacteristicsMsg = Vec<BluetoothCharacteristicMsg>; pub type BluetoothDescriptorsMsg = Vec<BluetoothDescriptorMsg>; -pub type BluetoothResult<T> = Result<T, String>; +pub type BluetoothResult<T> = Result<T, BluetoothError>; #[derive(Deserialize, Serialize)] pub enum BluetoothMethodMsg { diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs index 7deca26c9d3..c86fa0150a3 100644 --- a/components/script/dom/bluetooth.rs +++ b/components/script/dom/bluetooth.rs @@ -7,7 +7,7 @@ use core::clone::Clone; use dom::bindings::codegen::Bindings::BluetoothBinding; use dom::bindings::codegen::Bindings::BluetoothBinding::RequestDeviceOptions; use dom::bindings::codegen::Bindings::BluetoothBinding::{BluetoothScanFilter, BluetoothMethods}; -use dom::bindings::error::Error::{Security, Type}; +use dom::bindings::error::Error::{self, Security, Type}; use dom::bindings::error::Fallible; use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; @@ -19,7 +19,7 @@ use dom::bluetoothuuid::BluetoothUUID; use ipc_channel::ipc::{self, IpcSender}; use net_traits::bluetooth_scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence}; use net_traits::bluetooth_scanfilter::{RequestDeviceoptions, ServiceUUIDSequence}; -use net_traits::bluetooth_thread::BluetoothMethodMsg; +use net_traits::bluetooth_thread::{BluetoothError, BluetoothMethodMsg}; const FILTER_EMPTY_ERROR: &'static str = "'filters' member must be non - empty to find any devices."; const FILTER_ERROR: &'static str = "A filter must restrict the devices in some way."; @@ -135,6 +135,18 @@ fn convert_request_device_options(options: &RequestDeviceOptions, ServiceUUIDSequence::new(optional_services))) } +impl From<BluetoothError> for Error { + fn from(error: BluetoothError) -> Self { + match error { + BluetoothError::Type(message) => Error::Type(message), + BluetoothError::Network => Error::Network, + BluetoothError::NotFound => Error::NotFound, + BluetoothError::NotSupported => Error::NotSupported, + BluetoothError::Security => Error::Security, + } + } +} + impl BluetoothMethods for Bluetooth { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice fn RequestDevice(&self, option: &RequestDeviceOptions) -> Fallible<Root<BluetoothDevice>> { @@ -154,7 +166,7 @@ impl BluetoothMethods for Bluetooth { &ad_data)) }, Err(error) => { - Err(Type(error)) + Err(Error::from(error)) }, } } diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs index 8c520d7d4ca..0c27097625c 100644 --- a/components/script/dom/bluetoothremotegattcharacteristic.rs +++ b/components/script/dom/bluetoothremotegattcharacteristic.rs @@ -12,7 +12,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding:: BluetoothRemoteGATTCharacteristicMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; -use dom::bindings::error::Error::{InvalidModification, Network, NotSupported, Security, Type}; +use dom::bindings::error::Error::{self, InvalidModification, Network, NotSupported, Security}; use dom::bindings::error::{Fallible, ErrorResult}; use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, MutHeap, Root}; @@ -115,7 +115,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris descriptor.instance_id)) }, Err(error) => { - Err(Type(error)) + Err(Error::from(error)) }, } } @@ -147,7 +147,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris .collect()) }, Err(error) => { - Err(Type(error)) + Err(Error::from(error)) }, } } @@ -177,7 +177,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris ByteString::new(val) }, Err(error) => { - return Err(Type(error)) + return Err(Error::from(error)) }, }; *self.value.borrow_mut() = Some(value.clone()); @@ -208,7 +208,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris match result { Ok(_) => Ok(()), Err(error) => { - Err(Type(error)) + Err(Error::from(error)) }, } } diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs index f821d4aca2d..0ba52181b48 100644 --- a/components/script/dom/bluetoothremotegattdescriptor.rs +++ b/components/script/dom/bluetoothremotegattdescriptor.rs @@ -11,7 +11,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::{InvalidModification, Network, Security, Type}; +use dom::bindings::error::Error::{self, InvalidModification, Network, Security}; use dom::bindings::error::{Fallible, ErrorResult}; use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, MutHeap, Root}; @@ -101,7 +101,7 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor { ByteString::new(val) }, Err(error) => { - return Err(Type(error)) + return Err(Error::from(error)) }, }; *self.value.borrow_mut() = Some(value.clone()); @@ -126,7 +126,7 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor { match result { Ok(_) => Ok(()), Err(error) => { - Err(Type(error)) + Err(Error::from(error)) }, } } diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs index 56aad1b8bf6..f4b1e532f10 100644 --- a/components/script/dom/bluetoothremotegattserver.rs +++ b/components/script/dom/bluetoothremotegattserver.rs @@ -6,7 +6,7 @@ use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted}; use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; -use dom::bindings::error::Error::{Security, Type}; +use dom::bindings::error::Error::{self, Security}; use dom::bindings::error::{Fallible, ErrorResult}; use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, MutHeap, Root}; @@ -72,7 +72,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer { Ok(Root::from_ref(self)) }, Err(error) => { - Err(Type(error)) + Err(Error::from(error)) }, } } @@ -89,7 +89,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer { Ok(()) }, Err(error) => { - Err(Type(error)) + Err(Error::from(error)) }, } } @@ -113,7 +113,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer { service.instance_id)) }, Err(error) => { - Err(Type(error)) + Err(Error::from(error)) }, } } @@ -146,7 +146,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer { .collect()) }, Err(error) => { - Err(Type(error)) + Err(Error::from(error)) }, } } diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs index f0954a1c76f..5b80bc6afc0 100644 --- a/components/script/dom/bluetoothremotegattservice.rs +++ b/components/script/dom/bluetoothremotegattservice.rs @@ -5,7 +5,7 @@ use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted}; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; -use dom::bindings::error::Error::{Security, Type}; +use dom::bindings::error::Error::{self, Security}; use dom::bindings::error::Fallible; use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, MutHeap, Root}; @@ -115,7 +115,7 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService { characteristic.instance_id)) }, Err(error) => { - Err(Type(error)) + Err(Error::from(error)) }, } } @@ -160,7 +160,7 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService { Ok(characteristics) }, Err(error) => { - Err(Type(error)) + Err(Error::from(error)) }, } } @@ -188,7 +188,7 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService { service.instance_id)) }, Err(error) => { - Err(Type(error)) + Err(Error::from(error)) }, } } @@ -223,7 +223,7 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService { .collect()) }, Err(error) => { - Err(Type(error)) + Err(Error::from(error)) }, } } |