Chromium Code Reviews| Index: third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp |
| diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp |
| index 383649d5fa405a3c9da61f73c70abbcee2f0525a..8f1a9bd4c91b196a4830169ad0713b9d192706bc 100644 |
| --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp |
| +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp |
| @@ -9,15 +9,21 @@ |
| namespace blink { |
| -DOMException* BluetoothError::take(ScriptPromiseResolver*, |
| - mojom::blink::WebBluetoothResult error) { |
| +// static |
| +DOMException* BluetoothError::CreateDOMException( |
| + mojom::blink::WebBluetoothResult error, |
| + String detailedMessage) { |
| switch (error) { |
| case mojom::blink::WebBluetoothResult::SUCCESS: |
| ASSERT_NOT_REACHED(); |
| return DOMException::create(UnknownError); |
| -#define MAP_ERROR(enumeration, name, message) \ |
| - case mojom::blink::WebBluetoothResult::enumeration: \ |
| - return DOMException::create(name, message) |
| +#define MAP_ERROR(enumeration, name, message) \ |
| + case mojom::blink::WebBluetoothResult::enumeration: \ |
| + if (detailedMessage.isEmpty()) { \ |
| + return DOMException::create(name, message); \ |
| + } else { \ |
| + return DOMException::create(name, detailedMessage); \ |
|
dcheng
2017/02/09 19:16:41
FWIW, I'm not an owner of this code, but I'd prefe
perja
2017/02/10 13:28:16
Done.
|
| + } |
| // InvalidModificationErrors: |
| MAP_ERROR(GATT_INVALID_ATTRIBUTE_LENGTH, InvalidModificationError, |
| @@ -30,6 +36,12 @@ DOMException* BluetoothError::take(ScriptPromiseResolver*, |
| "GATT Characteristic no longer exists."); |
| MAP_ERROR(DESCRIPTOR_NO_LONGER_EXISTS, InvalidStateError, |
| "GATT Descriptor no longer exists."); |
| + MAP_ERROR(INVALID_CHARACTERISTIC, InvalidStateError, |
| + "Characteristic is no longer valid. Remember to retrieve the " |
| + "characteristic again after reconnecting."); |
| + MAP_ERROR(INVALID_DESCRIPTOR, InvalidStateError, |
| + "Descriptor is no longer valid. Remember to retrieve the " |
| + "Descriptor again after reconnecting."); |
| // NetworkErrors: |
| MAP_ERROR(CONNECT_ALREADY_IN_PROGRESS, NetworkError, |
| @@ -68,6 +80,10 @@ DOMException* BluetoothError::take(ScriptPromiseResolver*, |
| "GATT operation already in progress."); |
| MAP_ERROR(UNTRANSLATED_CONNECT_ERROR_CODE, NetworkError, |
| "Unknown ConnectErrorCode."); |
| + MAP_ERROR(GATT_SERVER_NOT_CONNECTED, NetworkError, |
| + "GATT Server is disconnected. Cannot perform GATT operations."); |
| + MAP_ERROR(GATT_SERVER_DISCONNECTED, NetworkError, |
| + "GATT Server disconnected while performing a GATT operation."); |
| // NotFoundErrors: |
| MAP_ERROR(WEB_BLUETOOTH_NOT_SUPPORTED, NotFoundError, |