Commit 0be9c69e authored by adamk's avatar adamk Committed by Commit bot

Increase the chance of printing a useful error when bootstrapping fails

Two changes:
  - In ReportBootstrappingException, if all we have is a string, it seems
    better to print that than nothing.
  - In Factory::NewError, there's no use trying to call into the builtins if
    compilation of the builtins is causing the exception (this currently
    results in a cryptic segfault if we trigger, say, a ReferenceError when
    executing builtins script during bootstrapping).

Review URL: https://codereview.chromium.org/1158013003

Cr-Commit-Position: refs/heads/master@{#28912}
parent fa041c90
......@@ -1061,6 +1061,13 @@ Handle<Object> Factory::NewError(const char* maker,
Handle<Object> arg2) {
HandleScope scope(isolate());
Handle<String> error_maker = InternalizeUtf8String(maker);
if (isolate()->bootstrapper()->IsActive()) {
// If this exception is being thrown during bootstrapping,
// js_builtins_object is unavailable. We return the error maker
// name's string as the exception since we have nothing better
// to do.
return scope.CloseAndEscape(error_maker);
}
Handle<Object> fun_obj = Object::GetProperty(isolate()->js_builtins_object(),
error_maker).ToHandleChecked();
......
......@@ -937,6 +937,9 @@ void ReportBootstrappingException(Handle<Object> exception,
"Extension or internal compilation error in %s at line %d.\n",
String::cast(location->script()->name())->ToCString().get(),
line_number);
} else if (exception->IsString()) {
base::OS::PrintError("Extension or internal compilation error: %s.\n",
String::cast(*exception)->ToCString().get());
} else {
base::OS::PrintError("Extension or internal compilation error.\n");
}
......
......@@ -41,6 +41,11 @@ void PendingCompilationErrorHandler::ThrowPendingError(Isolate* isolate,
break;
}
if (!error->IsJSObject()) {
isolate->Throw(*error, &location);
return;
}
Handle<JSObject> jserror = Handle<JSObject>::cast(error);
Handle<Name> key_start_pos = factory->error_start_pos_symbol();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment