Skip to content

Commit f820d44

Browse files
committed
QtScript/V8: Add new v8 api to check if a value is an error.
New function v8::Value::IsError was created. This API is experimental and added only for the purposes of our research.
1 parent 1859760 commit f820d44

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/3rdparty/v8/include/v8.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,11 @@ class Value : public Data {
946946
*/
947947
V8EXPORT bool IsRegExp() const;
948948

949+
/**
950+
* Returns true if this value is an Error.
951+
*/
952+
V8EXPORT bool IsError() const;
953+
949954
V8EXPORT Local<Boolean> ToBoolean() const;
950955
V8EXPORT Local<Number> ToNumber() const;
951956
V8EXPORT Local<String> ToString() const;

src/3rdparty/v8/src/api.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,6 +2113,12 @@ bool Value::IsRegExp() const {
21132113
return obj->IsJSRegExp();
21142114
}
21152115

2116+
bool Value::IsError() const {
2117+
if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsError()")) return false;
2118+
i::Handle<i::Object> obj = Utils::OpenHandle(this);
2119+
return obj->HasSpecificClassOf(HEAP->Error_symbol());
2120+
}
2121+
21162122

21172123
Local<String> Value::ToString() const {
21182124
i::Handle<i::Object> obj = Utils::OpenHandle(this);

src/3rdparty/v8/src/heap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ inline Heap* _inline_get_heap_();
169169
V(string_symbol, "string") \
170170
V(String_symbol, "String") \
171171
V(Date_symbol, "Date") \
172+
V(Error_symbol, "Error") \
172173
V(this_symbol, "this") \
173174
V(to_string_symbol, "toString") \
174175
V(char_at_symbol, "CharAt") \

0 commit comments

Comments
 (0)