Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(547)

Unified Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp

Issue 2564283004: bluetooth: web: Include the UUID in the error message. (Closed)
Patch Set: Addressed issues in code review. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698