Index: Source/modules/webusb/USBError.cpp |
diff --git a/Source/modules/webusb/USBError.cpp b/Source/modules/webusb/USBError.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..753eae8f4b693aa91ad5614a9bb88efa19c7d5a1 |
--- /dev/null |
+++ b/Source/modules/webusb/USBError.cpp |
@@ -0,0 +1,28 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "modules/webusb/USBError.h" |
+ |
+#include "core/dom/DOMException.h" |
+#include "core/dom/ExceptionCode.h" |
+#include "public/platform/modules/webusb/WebUSBError.h" |
+ |
+namespace blink { |
+ |
+DOMException* USBError::take(ScriptPromiseResolver*, PassOwnPtr<WebUSBError> webError) |
+{ |
+ switch (webError->errorType) { |
+ case WebUSBError::SecurityError: |
+ case WebUSBError::DeviceError: |
+ case WebUSBError::ServiceError: |
+ case WebUSBError::TransferError: |
+ // TODO(rockot): Differentiate between different error types. |
+ return DOMException::create(AbortError, webError->message); |
+ } |
+ ASSERT_NOT_REACHED(); |
+ return DOMException::create(UnknownError); |
+} |
+ |
+} // namespace blink |