| 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 cd703d4b3bb4f7a8e28b01d75e02d24a879ef29d..253e456b079d223cf2b22a57b3e06191635ca3f0 100644
|
| --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp
|
| +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp
|
| @@ -11,16 +11,28 @@
|
| namespace blink {
|
|
|
| DOMException* BluetoothError::take(
|
| - ScriptPromiseResolver*,
|
| + ScriptPromiseResolver* resolver,
|
| int32_t
|
| webError /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */) {
|
| + return take(resolver, webError, String());
|
| +}
|
| +
|
| +DOMException* BluetoothError::take(
|
| + ScriptPromiseResolver*,
|
| + int32_t
|
| + webError /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */,
|
| + String detailedMessage) {
|
| switch (static_cast<mojom::blink::WebBluetoothResult>(webError)) {
|
| 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); \
|
| + }
|
|
|
| // InvalidModificationErrors:
|
| MAP_ERROR(GATT_INVALID_ATTRIBUTE_LENGTH, InvalidModificationError,
|
| @@ -144,4 +156,10 @@ DOMException* BluetoothError::take(
|
| return DOMException::create(UnknownError);
|
| }
|
|
|
| +// static
|
| +bool BluetoothError::isSameError(int32_t error,
|
| + mojom::blink::WebBluetoothResult webError) {
|
| + return static_cast<mojom::blink::WebBluetoothResult>(error) == webError;
|
| +}
|
| +
|
| } // namespace blink
|
|
|