From f9b167deb07a650590b7f1eef8fe86bf9e22d211 Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Fri, 18 Jan 2019 12:15:09 -0800 Subject: Avoid crashes on ES module resolution when module not found (#1546) --- libdeno/binding.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libdeno') diff --git a/libdeno/binding.cc b/libdeno/binding.cc index d292f2638..000529304 100644 --- a/libdeno/binding.cc +++ b/libdeno/binding.cc @@ -558,7 +558,11 @@ v8::MaybeLocal ResolveCallback(v8::Local context, if (d->resolve_module_.IsEmpty()) { // Resolution Error. - isolate->ThrowException(v8_str("module resolution error")); + std::stringstream err_ss; + err_ss << "NotFound: Cannot resolve module \"" << specifier_c + << "\" from \"" << referrer_filename << "\""; + auto resolve_error = v8_str(err_ss.str().c_str()); + isolate->ThrowException(resolve_error); return v8::MaybeLocal(); } else { auto module = d->resolve_module_.Get(isolate); @@ -612,6 +616,8 @@ bool ExecuteMod(v8::Local context, const char* js_filename, auto module = maybe_module.ToLocalChecked(); auto maybe_ok = module->InstantiateModule(context, ResolveCallback); if (maybe_ok.IsNothing()) { + DCHECK(try_catch.HasCaught()); + HandleException(context, try_catch.Exception()); return false; } -- cgit v1.2.3