@@ -1127,7 +1127,7 @@ ssize_t DecodeWrite(char *buf,
1127
1127
return StringBytes::Write (buf, buflen, val, encoding, NULL );
1128
1128
}
1129
1129
1130
- void DisplayExceptionLine (Handle<Message> message) {
1130
+ void DisplayExceptionLine (Handle<Message> message) {
1131
1131
// Prevent re-entry into this function. For example, if there is
1132
1132
// a throw from a program in vm.runInThisContext(code, filename, true),
1133
1133
// 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) {
1194
1194
1195
1195
DisplayExceptionLine (message);
1196
1196
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 );
1199
1199
1200
1200
// range errors have a trace member set to undefined
1201
- if (trace.length () > 0 && !traceValue ->IsUndefined ()) {
1201
+ if (trace.length () > 0 && !trace_value ->IsUndefined ()) {
1202
1202
fprintf (stderr, " %s\n " , *trace);
1203
1203
} else {
1204
1204
// this really only happens for RangeErrors, since they're the only
@@ -1889,15 +1889,13 @@ void FatalException(Handle<Value> error, Handle<Message> message) {
1889
1889
1890
1890
Local<Function> fatal_f = Local<Function>::Cast (fatal_v);
1891
1891
1892
- Handle<Value> argv[] = { error };
1893
-
1894
1892
TryCatch fatal_try_catch;
1895
1893
1896
1894
// Do not call FatalException when _fatalException handler throws
1897
1895
fatal_try_catch.SetVerbose (false );
1898
1896
1899
1897
// 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 );
1901
1899
1902
1900
if (fatal_try_catch.HasCaught ()) {
1903
1901
// the fatal exception function threw, so we must exit
@@ -1912,15 +1910,17 @@ void FatalException(Handle<Value> error, Handle<Message> message) {
1912
1910
}
1913
1911
1914
1912
1915
- void FatalException (TryCatch & try_catch) {
1913
+ void FatalException (TryCatch& try_catch) {
1916
1914
HandleScope scope (node_isolate);
1917
1915
// TODO do not call FatalException if try_catch is verbose
1916
+ // (requires V8 API to expose getter for try_catch.is_verbose_)
1918
1917
FatalException (try_catch.Exception (), try_catch.Message ());
1919
1918
}
1920
1919
1921
1920
1922
1921
void 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).
1924
1924
FatalException (error, message);
1925
1925
}
1926
1926
@@ -2434,8 +2434,9 @@ void Load(Handle<Object> process_l) {
2434
2434
2435
2435
TryCatch try_catch;
2436
2436
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.
2439
2440
try_catch.SetVerbose (false );
2440
2441
2441
2442
Local<Value> f_value = ExecuteString (MainSource (),
@@ -2471,7 +2472,7 @@ void Load(Handle<Object> process_l) {
2471
2472
// (FatalException(), break on uncaught exception in debugger)
2472
2473
//
2473
2474
// 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
2475
2476
// thrown during process startup.
2476
2477
try_catch.SetVerbose (true );
2477
2478
0 commit comments