@@ -1127,7 +1127,7 @@ ssize_t DecodeWrite(char *buf,
11271127  return  StringBytes::Write (buf, buflen, val, encoding, NULL );
11281128}
11291129
1130- void  DisplayExceptionLine   (Handle<Message> message) {
1130+ void  DisplayExceptionLine (Handle<Message> message) {
11311131  //  Prevent re-entry into this function.  For example, if there is
11321132  //  a throw from a program in vm.runInThisContext(code, filename, true),
11331133  //  then we want to show the original failure, not the secondary one.
@@ -1194,11 +1194,11 @@ static void ReportException(Handle<Value> er, Handle<Message> message) {
11941194
11951195  DisplayExceptionLine (message);
11961196
1197-   Local<Value> traceValue (er->ToObject ()->Get (String::New (" stack" 
1198-   String::Utf8Value trace (traceValue );
1197+   Local<Value> trace_value (er->ToObject ()->Get (String::New (" stack" 
1198+   String::Utf8Value trace (trace_value );
11991199
12001200  //  range errors have a trace member set to undefined
1201-   if  (trace.length () > 0  && !traceValue ->IsUndefined ()) {
1201+   if  (trace.length () > 0  && !trace_value ->IsUndefined ()) {
12021202    fprintf (stderr, " %s\n " 
12031203  } else  {
12041204    //  this really only happens for RangeErrors, since they're the only
@@ -1889,15 +1889,13 @@ void FatalException(Handle<Value> error, Handle<Message> message) {
18891889
18901890  Local<Function> fatal_f = Local<Function>::Cast (fatal_v);
18911891
1892-   Handle<Value> argv[] = { error };
1893- 
18941892  TryCatch fatal_try_catch;
18951893
18961894  //  Do not call FatalException when _fatalException handler throws
18971895  fatal_try_catch.SetVerbose (false );
18981896
18991897  //  this will return true if the JS layer handled it, false otherwise
1900-   Local<Value> caught = fatal_f->Call (process, ARRAY_SIZE (argv), argv );
1898+   Local<Value> caught = fatal_f->Call (process, 1 , &error );
19011899
19021900  if  (fatal_try_catch.HasCaught ()) {
19031901    //  the fatal exception function threw, so we must exit
@@ -1912,15 +1910,17 @@ void FatalException(Handle<Value> error, Handle<Message> message) {
19121910}
19131911
19141912
1915- void  FatalException (TryCatch & try_catch) {
1913+ void  FatalException (TryCatch&  try_catch) {
19161914  HandleScope scope (node_isolate);
19171915  //  TODO do not call FatalException if try_catch is verbose
1916+   //  (requires V8 API to expose getter for try_catch.is_verbose_)
19181917  FatalException (try_catch.Exception (), try_catch.Message ());
19191918}
19201919
19211920
19221921void  OnMessage (Handle<Message> message, Handle<Value> error) {
1923-   //  TODO - check if exception is set?
1922+   //  The current version of V8 sends messages for errors only
1923+   //  (thus `error` is always set).
19241924  FatalException (error, message);
19251925}
19261926
@@ -2434,8 +2434,9 @@ void Load(Handle<Object> process_l) {
24342434
24352435  TryCatch try_catch;
24362436
2437-   //  try_catch must be not verbose to disable FatalException() handler
2438-   //  Load exceptions cannot be ignored (handled) by _fatalException
2437+   //  Disable verbose mode to stop FatalException() handler from trying
2438+   //  to handle the exception. Errors this early in the start-up phase
2439+   //  are not safe to ignore.
24392440  try_catch.SetVerbose (false );
24402441
24412442  Local<Value> f_value = ExecuteString (MainSource (),
@@ -2471,7 +2472,7 @@ void Load(Handle<Object> process_l) {
24712472  //  (FatalException(), break on uncaught exception in debugger)
24722473  // 
24732474  //  This is not strictly necessary since it's almost impossible
2474-   //  to attach debugger fast enought to break on exception
2475+   //  to attach the  debugger fast enought to break on exception
24752476  //  thrown during process startup.
24762477  try_catch.SetVerbose (true );
24772478
0 commit comments