summaryrefslogtreecommitdiff
path: root/core/libdeno
diff options
context:
space:
mode:
Diffstat (limited to 'core/libdeno')
-rw-r--r--core/libdeno/binding.cc38
-rw-r--r--core/libdeno/exceptions.cc9
-rw-r--r--core/libdeno/libdeno_test.cc9
3 files changed, 33 insertions, 23 deletions
diff --git a/core/libdeno/binding.cc b/core/libdeno/binding.cc
index ee379fc5b..da582a3bf 100644
--- a/core/libdeno/binding.cc
+++ b/core/libdeno/binding.cc
@@ -400,18 +400,21 @@ void EvalContext(const v8::FunctionCallbackInfo<v8::Value>& args) {
auto script = v8::Script::Compile(context, source, &origin);
if (script.IsEmpty()) {
- DCHECK(try_catch.HasCaught());
+ CHECK(try_catch.HasCaught());
auto exception = try_catch.Exception();
- output->Set(0, v8::Null(isolate));
+ CHECK(output->Set(context, 0, v8::Null(isolate)).FromJust());
auto errinfo_obj = v8::Object::New(isolate);
- errinfo_obj->Set(v8_str("isCompileError"), v8_bool(true));
- errinfo_obj->Set(v8_str("isNativeError"),
- v8_bool(exception->IsNativeError()));
- errinfo_obj->Set(v8_str("thrown"), exception);
+ CHECK(errinfo_obj->Set(context, v8_str("isCompileError"), v8_bool(true))
+ .FromJust());
+ CHECK(errinfo_obj
+ ->Set(context, v8_str("isNativeError"),
+ v8_bool(exception->IsNativeError()))
+ .FromJust());
+ CHECK(errinfo_obj->Set(context, v8_str("thrown"), exception).FromJust());
- output->Set(1, errinfo_obj);
+ CHECK(output->Set(context, 1, errinfo_obj).FromJust());
args.GetReturnValue().Set(output);
return;
@@ -420,25 +423,28 @@ void EvalContext(const v8::FunctionCallbackInfo<v8::Value>& args) {
auto result = script.ToLocalChecked()->Run(context);
if (result.IsEmpty()) {
- DCHECK(try_catch.HasCaught());
+ CHECK(try_catch.HasCaught());
auto exception = try_catch.Exception();
- output->Set(0, v8::Null(isolate));
+ CHECK(output->Set(context, 0, v8::Null(isolate)).FromJust());
auto errinfo_obj = v8::Object::New(isolate);
- errinfo_obj->Set(v8_str("isCompileError"), v8_bool(false));
- errinfo_obj->Set(v8_str("isNativeError"),
- v8_bool(exception->IsNativeError()));
- errinfo_obj->Set(v8_str("thrown"), exception);
+ CHECK(errinfo_obj->Set(context, v8_str("isCompileError"), v8_bool(false))
+ .FromJust());
+ CHECK(errinfo_obj
+ ->Set(context, v8_str("isNativeError"),
+ v8_bool(exception->IsNativeError()))
+ .FromJust());
+ CHECK(errinfo_obj->Set(context, v8_str("thrown"), exception).FromJust());
- output->Set(1, errinfo_obj);
+ CHECK(output->Set(context, 1, errinfo_obj).FromJust());
args.GetReturnValue().Set(output);
return;
}
- output->Set(0, result.ToLocalChecked());
- output->Set(1, v8::Null(isolate));
+ CHECK(output->Set(context, 0, result.ToLocalChecked()).FromJust());
+ CHECK(output->Set(context, 1, v8::Null(isolate)).FromJust());
args.GetReturnValue().Set(output);
}
diff --git a/core/libdeno/exceptions.cc b/core/libdeno/exceptions.cc
index 8f5779acd..7484e4eb4 100644
--- a/core/libdeno/exceptions.cc
+++ b/core/libdeno/exceptions.cc
@@ -90,9 +90,12 @@ v8::Local<v8::Object> EncodeMessageAsObject(v8::Local<v8::Context> context,
auto column = v8::Integer::New(isolate, frame->GetColumn());
CHECK(frame_obj->Set(context, v8_str("line"), line).FromJust());
CHECK(frame_obj->Set(context, v8_str("column"), column).FromJust());
- CHECK(frame_obj
- ->Set(context, v8_str("functionName"), frame->GetFunctionName())
- .FromJust());
+
+ auto function_name = frame->GetFunctionName();
+ if (!function_name.IsEmpty()) {
+ CHECK(frame_obj->Set(context, v8_str("functionName"), function_name)
+ .FromJust());
+ }
// scriptName can be empty in special conditions e.g. eval
auto scriptName = frame->GetScriptNameOrSourceURL();
if (scriptName.IsEmpty()) {
diff --git a/core/libdeno/libdeno_test.cc b/core/libdeno/libdeno_test.cc
index c2d76c876..16a4a11f6 100644
--- a/core/libdeno/libdeno_test.cc
+++ b/core/libdeno/libdeno_test.cc
@@ -115,7 +115,8 @@ TEST(LibDenoTest, GlobalErrorHandling) {
"\"lineNumber\":3,\"startPosition\":3,\"endPosition\":4,\"errorLevel\":8,"
"\"startColumn\":1,\"endColumn\":2,\"isSharedCrossOrigin\":false,"
"\"isOpaque\":false,\"frames\":[{\"line\":3,\"column\":2,"
- "\"functionName\":\"\",\"scriptName\":\"helloworld.js\",\"isEval\":true,"
+ "\"functionName\":\"eval\",\"scriptName\":\"helloworld.js\",\"isEval\":"
+ "true,"
"\"isConstructor\":false,\"isWasm\":false},";
std::string actual(deno_last_exception(d), 0, expected.length());
EXPECT_STREQ(expected.c_str(), actual.c_str());
@@ -177,7 +178,7 @@ TEST(LibDenoTest, LastException) {
"3,\"startPosition\":8,\"endPosition\":9,\"errorLevel\":8,"
"\"startColumn\":6,\"endColumn\":7,\"isSharedCrossOrigin\":"
"false,\"isOpaque\":false,\"frames\":[{\"line\":3,\"column\":7,"
- "\"functionName\":\"\",\"scriptName\":\"a.js\",\"isEval\":false,"
+ "\"scriptName\":\"a.js\",\"isEval\":false,"
"\"isConstructor\":false,\"isWasm\":false}]}");
deno_delete(d);
}
@@ -192,9 +193,9 @@ TEST(LibDenoTest, EncodeErrorBug) {
"defined\",\"sourceLine\":\"a\",\"lineNumber\":1,\"startPosition\":0,"
"\"endPosition\":1,\"errorLevel\":8,\"startColumn\":0,\"endColumn\":1,"
"\"isSharedCrossOrigin\":false,\"isOpaque\":false,\"frames\":[{\"line\":"
- "1,\"column\":1,\"functionName\":\"\",\"scriptName\":\"<unknown>\","
+ "1,\"column\":1,\"functionName\":\"eval\",\"scriptName\":\"<unknown>\","
"\"isEval\":true,\"isConstructor\":false,\"isWasm\":false},{\"line\":1,"
- "\"column\":1,\"functionName\":\"\",\"scriptName\":\"a.js\",\"isEval\":"
+ "\"column\":1,\"scriptName\":\"a.js\",\"isEval\":"
"false,\"isConstructor\":false,\"isWasm\":false}]}");
deno_delete(d);
}