Browse Source

Simplify exception reporting

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
53a841d96a
  1. 13
      src/node.cc

13
src/node.cc

@ -272,6 +272,7 @@ static void ReportException(TryCatch *try_catch) {
if (raw_stack->IsString()) stack = Handle<String>::Cast(raw_stack); if (raw_stack->IsString()) stack = Handle<String>::Cast(raw_stack);
} }
if (stack.IsEmpty()) {
// Print (filename):(line number): (message). // Print (filename):(line number): (message).
String::Utf8Value filename(message->GetScriptResourceName()); String::Utf8Value filename(message->GetScriptResourceName());
const char* filename_string = ToCString(filename); const char* filename_string = ToCString(filename);
@ -292,7 +293,6 @@ static void ReportException(TryCatch *try_catch) {
} }
fprintf(stderr, "\n"); fprintf(stderr, "\n");
if (stack.IsEmpty()) {
message->PrintCurrentStackTrace(stderr); message->PrintCurrentStackTrace(stderr);
} else { } else {
String::Utf8Value trace(stack); String::Utf8Value trace(stack);
@ -653,12 +653,11 @@ v8::Handle<v8::Value> Compile(const v8::Arguments& args) {
} }
static void OnFatalError(const char* location, const char* message) { static void OnFatalError(const char* location, const char* message) {
#define FATAL_ERROR "\033[1;31mV8 FATAL ERROR.\033[m" if (location) {
if (location) fprintf(stderr, "FATAL ERROR: %s %s\n", location, message);
fprintf(stderr, FATAL_ERROR " %s %s\n", location, message); } else {
else fprintf(stderr, "FATAL ERROR: %s\n", message);
fprintf(stderr, FATAL_ERROR " %s\n", message); }
exit(1); exit(1);
} }

Loading…
Cancel
Save