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

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

Issue 2721233002: bluetooth: Better disconnected error messages for characteristic retrieval. (Closed)
Patch Set: Address dcheng's comments Created 3 years, 9 months 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 bae9bb8c7879e103ada6a1489139b1bf6fe2c15b..1b15a01186470feda79f23127e54060261d8593d 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp
@@ -9,6 +9,32 @@
namespace blink {
+namespace {
+
+const char kGATTServerNotConnectedBase[] =
+ "GATT Server is disconnected. "
+ "Cannot %s. (Re)connect first with `device.gatt.connect`.";
+
+} // namespace
+
+// static
+DOMException* BluetoothError::createNotConnectedException(
+ BluetoothOperation operation) {
+ const char* operationString = nullptr;
+ switch (operation) {
+ case BluetoothOperation::ServicesRetrieval:
+ operationString = "retrieve services";
+ break;
+ case BluetoothOperation::CharacteristicsRetrieval:
+ operationString = "retrieve characteristics";
+ break;
+ }
+
+ return DOMException::create(
+ NetworkError,
+ String::format(kGATTServerNotConnectedBase, operationString));
+}
+
// static
DOMException* BluetoothError::createDOMException(
BluetoothErrorCode error,
@@ -98,13 +124,6 @@ DOMException* BluetoothError::createDOMException(
"GATT Server is disconnected. Cannot perform GATT operations.");
MAP_ERROR(GATT_SERVER_DISCONNECTED, NetworkError,
"GATT Server disconnected while performing a GATT operation.");
- MAP_ERROR(GATT_SERVER_DISCONNECTED_WHILE_RETRIEVING_CHARACTERISTICS,
- NetworkError,
- "GATT Server disconnected while retrieving characteristics.");
- MAP_ERROR(
- GATT_SERVER_NOT_CONNECTED_CANNOT_RETRIEVE_CHARACTERISTICS,
- NetworkError,
- "GATT Server is disconnected. Cannot retrieve characteristics.");
// NotFoundErrors:
MAP_ERROR(WEB_BLUETOOTH_NOT_SUPPORTED, NotFoundError,

Powered by Google App Engine
This is Rietveld 408576698