Index: Source/modules/mediasession/MediaSessionError.cpp |
diff --git a/Source/modules/mediasession/MediaSessionError.cpp b/Source/modules/mediasession/MediaSessionError.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..18974ba5fcd6d0c75eae47b8461cd790a28e93a2 |
--- /dev/null |
+++ b/Source/modules/mediasession/MediaSessionError.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/mediasession/MediaSessionError.h" |
+ |
+#include "bindings/core/v8/ScriptPromiseResolver.h" |
+ |
+namespace blink { |
+ |
+// static |
+v8::Local<v8::Value> MediaSessionError::take(ScriptPromiseResolver* resolver, const WebMediaSessionError& webError) |
+{ |
+ v8::Isolate* isolate = resolver->scriptState()->isolate(); |
+ |
+ switch (webError.errorType) { |
+ case WebMediaSessionError::ErrorTypeActivate: |
+ return v8::Exception::TypeError(v8String(isolate, "The media session activation failed.")); |
+ case WebMediaSessionError::ErrorTypeUnknown: |
+ return v8::Exception::Error(v8String(isolate, "An unknown error occurred within media session.")); |
+ } |
+ |
+ ASSERT_NOT_REACHED(); |
+ return v8::Exception::Error(v8String(isolate, "An unknown error occurred.")); |
+} |
+ |
+} // namespace blink |