Shaka Player Embedded
js_error.h
Go to the documentation of this file.
1 // Copyright 2016 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef SHAKA_EMBEDDED_JS_JS_ERROR_H_
16 #define SHAKA_EMBEDDED_JS_JS_ERROR_H_
17 
18 #include <string>
19 
22 
23 namespace shaka {
24 namespace js {
25 
30 class JsError {
31  public:
32  static std::string GetJsStack();
33 
34  static JsError RangeError(const std::string& message);
35  static JsError ReferenceError(const std::string& message);
36  static JsError TypeError(const std::string& message);
37  static JsError SyntaxError(const std::string& message);
38  static JsError Error(const std::string& message);
39 
40  static JsError Rethrow(Handle<JsValue> error);
41 
42 #ifdef USING_V8
43  static JsError Rethrow(const v8::TryCatch& trycatch);
44 #endif
45 
46  static JsError DOMException(ExceptionCode code);
47  static JsError DOMException(ExceptionCode code, const std::string& message);
48 
49  ~JsError();
50  JsError(JsError&&);
51 
52  ReturnVal<JsValue> error() const {
53  return error_;
54  }
55 
56  private:
57  explicit JsError(ReturnVal<JsValue> error);
58 
59  ReturnVal<JsValue> error_;
60 };
61 
62 } // namespace js
63 } // namespace shaka
64 
65 #endif // SHAKA_EMBEDDED_JS_JS_ERROR_H_
static JsError Error(const std::string &message)
Definition: js_error.cc:97
static JsError Rethrow(Handle< JsValue > error)
Definition: js_error.cc:105
JsError(JsError &&)
static std::string GetJsStack()
Definition: js_error.cc:47
static JsError SyntaxError(const std::string &message)
Definition: js_error.cc:89
ReturnVal< JsValue > error() const
Definition: js_error.h:52
static JsError TypeError(const std::string &message)
Definition: js_error.cc:81
static JsError DOMException(ExceptionCode code)
Definition: js_error.cc:115
const char * message
static JsError RangeError(const std::string &message)
Definition: js_error.cc:65
static JsError ReferenceError(const std::string &message)
Definition: js_error.cc:73