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