Commit ff5194e3 authored by clemensh's avatar clemensh Committed by Commit bot

Improve exception printing for debug

If there is no stack trace (which happens), then at least print the
location of the message.

R=titzer@chromium.org,ahaas@chromium.org

Review-Url: https://codereview.chromium.org/2450253002
Cr-Commit-Position: refs/heads/master@{#40599}
parent 46a1b34e
......@@ -1072,6 +1072,30 @@ Object* Isolate::Throw(Object* exception, MessageLocation* location) {
if (FLAG_print_all_exceptions) {
printf("=========================================================\n");
printf("Exception thrown:\n");
if (location) {
Handle<Script> script = location->script();
Handle<Object> name = Script::GetNameOrSourceURL(script);
printf("at ");
if (name->IsString() && String::cast(*name)->length() > 0)
String::cast(*name)->PrintOn(stdout);
else
printf("<anonymous>");
// Script::GetLineNumber and Script::GetColumnNumber can allocate on the heap to
// initialize the line_ends array, so be careful when calling them.
#ifdef DEBUG
if (AllowHeapAllocation::IsAllowed()) {
#else
if (false) {
#endif
printf(", %d:%d - %d:%d\n",
Script::GetLineNumber(script, location->start_pos()) + 1,
Script::GetColumnNumber(script, location->start_pos()),
Script::GetLineNumber(script, location->end_pos()) + 1,
Script::GetColumnNumber(script, location->end_pos()));
} else {
printf(", line %d\n", script->GetLineNumber(location->start_pos()) + 1);
}
}
exception->Print();
printf("Stack Trace:\n");
PrintStack(stdout);
......
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