-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNativeScriptException.h
More file actions
52 lines (39 loc) · 1.56 KB
/
NativeScriptException.h
File metadata and controls
52 lines (39 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef NativeScriptException_h
#define NativeScriptException_h
#include <string>
#include "js_native_api.h"
#include "js_native_api_types.h"
namespace nativescript {
class NativeScriptException {
public:
NativeScriptException(const std::string& message);
NativeScriptException(const std::string& message,
const std::string& stackTrace);
NativeScriptException(napi_env env, napi_value error,
const std::string& message,
const std::string& name = "NativeScriptException");
NativeScriptException(napi_env env, const std::string& message,
const std::string& name = "NativeScriptException");
void ReThrowToJS(napi_env env, napi_value* errorOut = nullptr);
static void OnUncaughtError(napi_env env, napi_value error);
inline std::string Name() const {
if (name_.empty()) {
return "NativeScriptException";
}
return name_;
}
std::string Description() const;
private:
std::string name_;
std::string message_;
std::string stackTrace_;
std::string fullMessage_;
static std::string GetErrorStackTrace(napi_env env, napi_value stackTrace);
static std::string GetErrorMessage(napi_env env, napi_value error,
const std::string& prependMessage = "");
std::string GetFullMessage(napi_env env, napi_value error,
const std::string& jsExceptionMessage);
static void PrintErrorMessage(const std::string& errorMessage);
};
} // namespace nativescript
#endif /* NativeScriptException_h */