| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/bluetooth/BluetoothError.h" | 6 #include "modules/bluetooth/BluetoothError.h" |
| 7 | 7 |
| 8 #include "core/dom/DOMException.h" | 8 #include "core/dom/DOMException.h" |
| 9 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 DOMException* BluetoothError::take(ScriptPromiseResolver*, PassOwnPtr<WebBluetoo
thError> webError) | 13 DOMException* BluetoothError::take(ScriptPromiseResolver*, const WebBluetoothErr
or& webError) |
| 14 { | 14 { |
| 15 switch (webError->errorType) { | 15 switch (webError.errorType) { |
| 16 case WebBluetoothError::AbortError: | 16 case WebBluetoothError::AbortError: |
| 17 return DOMException::create(AbortError, webError->message); | 17 return DOMException::create(AbortError, webError.message); |
| 18 case WebBluetoothError::InvalidModificationError: | 18 case WebBluetoothError::InvalidModificationError: |
| 19 return DOMException::create(InvalidModificationError, webError->message)
; | 19 return DOMException::create(InvalidModificationError, webError.message); |
| 20 case WebBluetoothError::InvalidStateError: | 20 case WebBluetoothError::InvalidStateError: |
| 21 return DOMException::create(InvalidStateError, webError->message); | 21 return DOMException::create(InvalidStateError, webError.message); |
| 22 case WebBluetoothError::NetworkError: | 22 case WebBluetoothError::NetworkError: |
| 23 return DOMException::create(NetworkError, webError->message); | 23 return DOMException::create(NetworkError, webError.message); |
| 24 case WebBluetoothError::NotFoundError: | 24 case WebBluetoothError::NotFoundError: |
| 25 return DOMException::create(NotFoundError, webError->message); | 25 return DOMException::create(NotFoundError, webError.message); |
| 26 case WebBluetoothError::NotSupportedError: | 26 case WebBluetoothError::NotSupportedError: |
| 27 return DOMException::create(NotSupportedError, webError->message); | 27 return DOMException::create(NotSupportedError, webError.message); |
| 28 case WebBluetoothError::SecurityError: | 28 case WebBluetoothError::SecurityError: |
| 29 return DOMException::create(SecurityError, webError->message); | 29 return DOMException::create(SecurityError, webError.message); |
| 30 case WebBluetoothError::SyntaxError: | 30 case WebBluetoothError::SyntaxError: |
| 31 return DOMException::create(SyntaxError, webError->message); | 31 return DOMException::create(SyntaxError, webError.message); |
| 32 case WebBluetoothError::ErrorMessage: | 32 case WebBluetoothError::ErrorMessage: |
| 33 // Handled below so I can maintain the indentation when this switch goes
away. | 33 // Handled below so I can maintain the indentation when this switch goes
away. |
| 34 break; | 34 break; |
| 35 } | 35 } |
| 36 | 36 |
| 37 switch (webError->errorMessage) { | 37 switch (webError.errorMessage) { |
| 38 #define MAP_ERROR(enumeration, name, message) \ | 38 #define MAP_ERROR(enumeration, name, message) \ |
| 39 case WebBluetoothErrorMessage::enumeration: \ | 39 case WebBluetoothErrorMessage::enumeration: \ |
| 40 return DOMException::create(name, message) | 40 return DOMException::create(name, message) |
| 41 | 41 |
| 42 // InvalidModificationErrors: | 42 // InvalidModificationErrors: |
| 43 MAP_ERROR(GATTInvalidAttributeLength, InvalidModificationError, "GATT Er
ror: invalid attribute length."); | 43 MAP_ERROR(GATTInvalidAttributeLength, InvalidModificationError, "GATT Er
ror: invalid attribute length."); |
| 44 | 44 |
| 45 // InvalidStateErrors: | 45 // InvalidStateErrors: |
| 46 MAP_ERROR(ServiceNoLongerExists, InvalidStateError, "GATT Service no lon
ger exists."); | 46 MAP_ERROR(ServiceNoLongerExists, InvalidStateError, "GATT Service no lon
ger exists."); |
| 47 MAP_ERROR(CharacteristicNoLongerExists, InvalidStateError, "GATT Charact
eristic no longer exists."); | 47 MAP_ERROR(CharacteristicNoLongerExists, InvalidStateError, "GATT Charact
eristic no longer exists."); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 MAP_ERROR(GATTNotAuthorized, SecurityError, "GATT operation not authoriz
ed."); | 79 MAP_ERROR(GATTNotAuthorized, SecurityError, "GATT operation not authoriz
ed."); |
| 80 | 80 |
| 81 #undef MAP_ERROR | 81 #undef MAP_ERROR |
| 82 } | 82 } |
| 83 | 83 |
| 84 ASSERT_NOT_REACHED(); | 84 ASSERT_NOT_REACHED(); |
| 85 return DOMException::create(UnknownError); | 85 return DOMException::create(UnknownError); |
| 86 } | 86 } |
| 87 | 87 |
| 88 } // namespace blink | 88 } // namespace blink |
| OLD | NEW |