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