Index: src/d8.cc |
diff --git a/src/d8.cc b/src/d8.cc |
index 6eb7248b0e8fa0d84b802f59132cf29c1931d0c6..96407a897c98b1284a3f9b1dd78bb457c5b08bd7 100644 |
--- a/src/d8.cc |
+++ b/src/d8.cc |
@@ -1231,6 +1231,7 @@ SourceGroup::~SourceGroup() { |
void SourceGroup::Execute(Isolate* isolate) { |
+ bool exception_was_thrown = false; |
for (int i = begin_offset_; i < end_offset_; ++i) { |
const char* arg = argv_[i]; |
if (strcmp(arg, "-e") == 0 && i + 1 < end_offset_) { |
@@ -1239,7 +1240,8 @@ void SourceGroup::Execute(Isolate* isolate) { |
Handle<String> file_name = String::New("unnamed"); |
Handle<String> source = String::New(argv_[i + 1]); |
if (!Shell::ExecuteString(isolate, source, file_name, false, true)) { |
- Shell::Exit(1); |
+ exception_was_thrown = true; |
+ break; |
} |
++i; |
} else if (arg[0] == '-') { |
@@ -1254,10 +1256,14 @@ void SourceGroup::Execute(Isolate* isolate) { |
Shell::Exit(1); |
} |
if (!Shell::ExecuteString(isolate, source, file_name, false, true)) { |
- Shell::Exit(1); |
+ exception_was_thrown = true; |
+ break; |
} |
} |
} |
+ if (exception_was_thrown != Shell::options.expected_to_throw) { |
+ Shell::Exit(1); |
+ } |
} |
@@ -1413,6 +1419,9 @@ bool Shell::SetOptions(int argc, char* argv[]) { |
options.dump_heap_constants = true; |
argv[i] = NULL; |
#endif |
+ } else if (strcmp(argv[i], "--throws") == 0) { |
+ options.expected_to_throw = true; |
+ argv[i] = NULL; |
} |
#ifdef V8_SHARED |
else if (strcmp(argv[i], "--dump-counters") == 0) { |