Commit b120482d authored by scheib@chromium.org's avatar scheib@chromium.org

bluetooth: Explain why standard names aren't recognized in error message.

Developers are expressing confusion when passing invalid service names,
sometimes because they pass an invalid UUID that nearly looks correct.
Explain more explicitly in the error message what is accepted.

BUG=491441

Review URL: https://codereview.chromium.org/1315443007

git-svn-id: svn://svn.chromium.org/blink/trunk@201234 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 11dd8e4c
......@@ -109,7 +109,13 @@ promise_test(() => {
name: 'SyntaxError',
message: 'Failed to execute \'getCharacteristic\' on ' +
'\'BluetoothGATTService\': \Invalid Characteristic name: ' +
'\'wrong_name\'.'
'\'wrong_name\'. ' +
'It must be a valid UUID alias (e.g. 0x1234), ' +
'UUID (lowercase hex characters e.g. ' +
'\'00001234-0000-1000-8000-00805f9b34fb\'), ' +
'or recognized standard name from ' +
'https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicsHome.aspx' +
' e.g. \'aerobic_heart_rate_lower_limit\'.'
}, 'Wrong Characteristic name passed.');
});
}, 'Wrong Characteristic name. Reject with SyntaxError.');
......
......@@ -88,7 +88,13 @@ promise_test(() => {
name: 'SyntaxError',
message: 'Failed to execute \'getPrimaryService\' on ' +
'\'BluetoothGATTRemoteServer\': Invalid Service name: ' +
'\'wrong_name\'.'
'\'wrong_name\'. ' +
'It must be a valid UUID alias (e.g. 0x1234), ' +
'UUID (lowercase hex characters e.g. ' +
'\'00001234-0000-1000-8000-00805f9b34fb\'), ' +
'or recognized standard name from ' +
'https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx' +
' e.g. \'alert_notification\'.'
}, 'Wrong Service name passed.');
});
}, 'Wrong Service name. Reject with SyntaxError.');
......
......@@ -311,7 +311,23 @@ String getUUIDForGATTAttribute(GATTAttribute attribute, StringOrUnsignedLong nam
errorMessage.append(attributeType);
errorMessage.append(" name: '");
errorMessage.append(nameStr);
errorMessage.append("'.");
errorMessage.append("'. It must be a valid UUID alias (e.g. 0x1234), "
"UUID (lowercase hex characters e.g. '00001234-0000-1000-8000-00805f9b34fb'), "
"or recognized standard name from ");
switch (attribute) {
case GATTAttribute::Service:
errorMessage.append("https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx"
" e.g. 'alert_notification'.");
break;
case GATTAttribute::Characteristic:
errorMessage.append("https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicsHome.aspx"
" e.g. 'aerobic_heart_rate_lower_limit'.");
break;
case GATTAttribute::Descriptor:
errorMessage.append("https://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorsHomePage.aspx"
" e.g. 'gatt.characteristic_presentation_format'.");
break;
}
// Otherwise, throw a SyntaxError.
exceptionState.throwDOMException(SyntaxError, errorMessage.toString());
return String();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment