Chromium Code Reviews| Index: src/liveedit.cc |
| diff --git a/src/liveedit.cc b/src/liveedit.cc |
| index 574a37691c0a0e99e0e46617455d734ff7e50d2c..f2b9977efa4fc42d4280bede710319d3cf989f57 100644 |
| --- a/src/liveedit.cc |
| +++ b/src/liveedit.cc |
| @@ -925,11 +925,68 @@ JSArray* LiveEdit::GatherCompileInfo(Handle<Script> script, |
| Handle<Object> original_source = Handle<Object>(script->source()); |
| script->set_source(*source); |
| isolate->set_active_function_info_listener(&listener); |
| - CompileScriptForTracker(isolate, script); |
| + |
| + Handle<Object> rethrow_exception; |
| + { |
| + // Creating TryCatch from public API is currently the only way to get |
| + // message object. Without TryCatch the message object won't even be |
| + // prepared at all. |
| + v8::TryCatch try_catch; |
| + try_catch.SetVerbose(true); |
| + |
| + // A logical 'try' section. |
| + CompileScriptForTracker(isolate, script); |
| + |
| + // A logical 'catch' section. |
| + if (isolate->has_pending_exception()) { |
| + isolate->ReportPendingMessages(); |
| + isolate->clear_pending_exception(); |
|
Yang
2012/11/29 16:38:57
If I'm not mistaken, ReportPendingMessages() alrea
Peter Rybin
2012/11/29 23:16:05
It does clear message. I don't see that it clears
|
| + isolate->clear_pending_message(); |
| + } |
| + if (!try_catch.Exception().IsEmpty()) { |
|
Yang
2012/11/29 16:38:57
use try_catch.HasCaught() seems cleaner.
Peter Rybin
2012/11/29 23:16:05
Done.
|
| + Handle<Object> exception = |
| + Utils::OpenHandle(*try_catch.Exception(), false); |
| + |
| + // If possible, copy positions from message object to exception object. |
| + if (exception->IsJSObject() && !try_catch.Message().IsEmpty()) { |
|
Yang
2012/11/29 16:38:57
It seems that GetLineNumber() and the Get*Column()
Peter Rybin
2012/11/29 23:16:05
Done.
|
| + Handle<JSObject> exception_struct = Handle<JSObject>::cast(exception); |
| + |
| + Factory* factory = isolate->factory(); |
| + JSReceiver::SetProperty(exception_struct, |
| + factory->LookupAsciiSymbol("startLine"), |
| + Handle<Smi>(Smi::FromInt(try_catch.Message()->GetLineNumber())), |
| + NONE, kNonStrictMode); |
| + JSReceiver::SetProperty(exception_struct, |
| + factory->LookupAsciiSymbol("startPosition"), |
| + Handle<Smi>(Smi::FromInt(try_catch.Message()->GetStartPosition())), |
| + NONE, kNonStrictMode); |
| + JSReceiver::SetProperty(exception_struct, |
| + factory->LookupAsciiSymbol("endPosition"), |
| + Handle<Smi>(Smi::FromInt(try_catch.Message()->GetEndPosition())), |
| + NONE, kNonStrictMode); |
| + JSReceiver::SetProperty(exception_struct, |
| + factory->LookupAsciiSymbol("startColumn"), |
| + Handle<Smi>(Smi::FromInt(try_catch.Message()->GetStartColumn())), |
| + NONE, kNonStrictMode); |
| + JSReceiver::SetProperty(exception_struct, |
| + factory->LookupAsciiSymbol("endColumn"), |
| + Handle<Smi>(Smi::FromInt(try_catch.Message()->GetEndColumn())), |
| + NONE, kNonStrictMode); |
| + } |
| + |
| + rethrow_exception = exception; |
| + } |
| + } |
| + |
| isolate->set_active_function_info_listener(NULL); |
| script->set_source(*original_source); |
| - return *(listener.GetResult()); |
| + if (rethrow_exception.is_null()) { |
|
Yang
2012/11/29 16:38:57
Would it be possible to use try_catch.ReThrow()?
Peter Rybin
2012/11/29 23:16:05
I don't see a nice way to reach TryCatch outside f
|
| + return *(listener.GetResult()); |
| + } else { |
| + isolate->Throw(*rethrow_exception); |
| + return 0; |
| + } |
| } |