Reviewers: Sven Panne,

Message:
plz review

Description:
Also print the exception when mksnapshot failed to compile extra code.

Before, it would only print the exception when it failed to run the code

Please review this at https://codereview.chromium.org/14031036/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/mksnapshot.cc


Index: src/mksnapshot.cc
diff --git a/src/mksnapshot.cc b/src/mksnapshot.cc
index abfe69397b0998927fd7d2c0a498de38f64780a2..91058ad00cf8f2e87f020465deb1d81176311b74 100644
--- a/src/mksnapshot.cc
+++ b/src/mksnapshot.cc
@@ -291,6 +291,24 @@ class BZip2Decompressor : public StartupDataDecompressor {
 #endif


+void DumpException(Handle<Message> message) {
+  Local<String> message_string = message->Get();
+  Local<String> message_line = message->GetSourceLine();
+  int len = 2 + message_string->Utf8Length() + message_line->Utf8Length();
+  char* buf = new char(len);
+  message_string->WriteUtf8(buf);
+  fprintf(stderr, "%s at line %d\n", buf, message->GetLineNumber());
+  message_line->WriteUtf8(buf);
+  fprintf(stderr, "%s\n", buf);
+  int from = message->GetStartColumn();
+  int to = message->GetEndColumn();
+  int i;
+  for (i = 0; i < from; i++) fprintf(stderr, " ");
+  for ( ; i <= to; i++) fprintf(stderr, "^");
+  fprintf(stderr, "\n");
+}
+
+
 int main(int argc, char** argv) {
   // By default, log code create information in the snapshot.
   i::FLAG_log_code = true;
@@ -350,27 +368,14 @@ int main(int argc, char** argv) {
     TryCatch try_catch;
     Local<Script> script = Script::Compile(source);
     if (try_catch.HasCaught()) {
-      fprintf(stderr, "Failure compiling '%s' (see above)\n", name);
+      fprintf(stderr, "Failure compiling '%s'\n", name);
+      DumpException(try_catch.Message());
       exit(1);
     }
     script->Run();
     if (try_catch.HasCaught()) {
       fprintf(stderr, "Failure running '%s'\n", name);
-      Local<Message> message = try_catch.Message();
-      Local<String> message_string = message->Get();
-      Local<String> message_line = message->GetSourceLine();
- int len = 2 + message_string->Utf8Length() + message_line->Utf8Length();
-      char* buf = new char(len);
-      message_string->WriteUtf8(buf);
-      fprintf(stderr, "%s at line %d\n", buf, message->GetLineNumber());
-      message_line->WriteUtf8(buf);
-      fprintf(stderr, "%s\n", buf);
-      int from = message->GetStartColumn();
-      int to = message->GetEndColumn();
-      int i;
-      for (i = 0; i < from; i++) fprintf(stderr, " ");
-      for ( ; i <= to; i++) fprintf(stderr, "^");
-      fprintf(stderr, "\n");
+      DumpException(try_catch.Message());
       exit(1);
     }
     context->Exit();


--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to