OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/nfc/NFCError.h" | 5 #include "modules/nfc/NFCError.h" |
6 | 6 |
7 #include "core/dom/DOMException.h" | 7 #include "core/dom/DOMException.h" |
8 #include "core/dom/ExceptionCode.h" | 8 #include "core/dom/ExceptionCode.h" |
9 | 9 |
10 using device::nfc::blink::NFCErrorType; | 10 using device::nfc::mojom::blink::NFCErrorType; |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 DOMException* NFCError::take(ScriptPromiseResolver*, const NFCErrorType& errorTy
pe) | 14 DOMException* NFCError::take(ScriptPromiseResolver*, const NFCErrorType& errorTy
pe) |
15 { | 15 { |
16 switch (errorType) { | 16 switch (errorType) { |
17 case NFCErrorType::SECURITY: | 17 case NFCErrorType::SECURITY: |
18 return DOMException::create(SecurityError, "NFC operation not allowed.")
; | 18 return DOMException::create(SecurityError, "NFC operation not allowed.")
; |
19 case NFCErrorType::NOT_SUPPORTED: | 19 case NFCErrorType::NOT_SUPPORTED: |
20 case NFCErrorType::DEVICE_DISABLED: | 20 case NFCErrorType::DEVICE_DISABLED: |
21 return DOMException::create(NotSupportedError, "NFC operation not suppor
ted."); | 21 return DOMException::create(NotSupportedError, "NFC operation not suppor
ted."); |
22 case NFCErrorType::NOT_FOUND: | 22 case NFCErrorType::NOT_FOUND: |
23 return DOMException::create(NotFoundError, "Invalid NFC watch Id was pro
vided."); | 23 return DOMException::create(NotFoundError, "Invalid NFC watch Id was pro
vided."); |
24 case NFCErrorType::INVALID_MESSAGE: | 24 case NFCErrorType::INVALID_MESSAGE: |
25 return DOMException::create(SyntaxError, "Invalid NFC message was provid
ed."); | 25 return DOMException::create(SyntaxError, "Invalid NFC message was provid
ed."); |
26 case NFCErrorType::OPERATION_CANCELLED: | 26 case NFCErrorType::OPERATION_CANCELLED: |
27 return DOMException::create(AbortError, "The NFC operation was cancelled
."); | 27 return DOMException::create(AbortError, "The NFC operation was cancelled
."); |
28 case NFCErrorType::TIMER_EXPIRED: | 28 case NFCErrorType::TIMER_EXPIRED: |
29 return DOMException::create(TimeoutError, "NFC operation has timed-out."
); | 29 return DOMException::create(TimeoutError, "NFC operation has timed-out."
); |
30 case NFCErrorType::CANNOT_CANCEL: | 30 case NFCErrorType::CANNOT_CANCEL: |
31 return DOMException::create(NoModificationAllowedError, "NFC operation c
annot be canceled."); | 31 return DOMException::create(NoModificationAllowedError, "NFC operation c
annot be canceled."); |
32 case NFCErrorType::IO_ERROR: | 32 case NFCErrorType::IO_ERROR: |
33 return DOMException::create(NetworkError, "NFC data transfer error has o
ccurred."); | 33 return DOMException::create(NetworkError, "NFC data transfer error has o
ccurred."); |
34 } | 34 } |
35 NOTREACHED(); | 35 NOTREACHED(); |
36 return DOMException::create(UnknownError, "An unknown NFC error has occurred
."); | 36 return DOMException::create(UnknownError, "An unknown NFC error has occurred
."); |
37 } | 37 } |
38 | 38 |
39 } // namespace blink | 39 } // namespace blink |
OLD | NEW |