From 8936de814ae6e70889ea85d04a469a5bcc01ef37 Mon Sep 17 00:00:00 2001 From: Andrew Paprocki Date: Sun, 2 Jun 2013 13:08:43 -0400 Subject: [PATCH 1/2] vm: Remove display_error hack. --- src/node_script.cc | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/node_script.cc b/src/node_script.cc index 30d20022f118..7d119987303b 100644 --- a/src/node_script.cc +++ b/src/node_script.cc @@ -342,15 +342,6 @@ void WrappedScript::EvalMachine(const FunctionCallbackInfo& args) { timeout = args[timeout_index]->Uint32Value(); } - const int display_error_index = timeout_index + - (timeout_flag == noTimeout ? 0 : 1); - bool display_error = false; - if (args.Length() > display_error_index && - args[display_error_index]->IsBoolean() && - args[display_error_index]->BooleanValue() == true) { - display_error = true; - } - Local context = Context::GetCurrent(); Local keys; @@ -389,10 +380,6 @@ void WrappedScript::EvalMachine(const FunctionCallbackInfo& args) { script = output_flag == returnResult ? Script::Compile(code, filename) : Script::New(code, filename); if (script.IsEmpty()) { - // FIXME UGLY HACK TO DISPLAY SYNTAX ERRORS. - if (display_error) DisplayExceptionLine(try_catch.Message()); - - // Hack because I can't get a proper stacktrace on SyntaxError try_catch.ReThrow(); return; } @@ -420,7 +407,6 @@ void WrappedScript::EvalMachine(const FunctionCallbackInfo& args) { return ThrowError("Script execution timed out."); } if (result.IsEmpty()) { - if (display_error) DisplayExceptionLine(try_catch.Message()); try_catch.ReThrow(); return; } From 8f30fedbfded7359a5b7265f92b05deb8cc84b4a Mon Sep 17 00:00:00 2001 From: Andrew Paprocki Date: Tue, 25 Jun 2013 23:27:21 -0400 Subject: [PATCH 2/2] vm: Add test case for TryCatch fix. --- test/message/vm_syntax_error.js | 31 +++++++++++++++++++++++++++++++ test/message/vm_syntax_error.out | 6 ++++++ 2 files changed, 37 insertions(+) create mode 100644 test/message/vm_syntax_error.js create mode 100644 test/message/vm_syntax_error.out diff --git a/test/message/vm_syntax_error.js b/test/message/vm_syntax_error.js new file mode 100644 index 000000000000..51f53841f7c7 --- /dev/null +++ b/test/message/vm_syntax_error.js @@ -0,0 +1,31 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var common = require('../common'); +var assert = require('assert'); +var vm = require('vm'); + +var context = { + run: function() { + vm.runInNewContext('invalid ?= 1', context, 'bar'); + } +}; +vm.runInNewContext('run()', context, 'foo'); diff --git a/test/message/vm_syntax_error.out b/test/message/vm_syntax_error.out new file mode 100644 index 000000000000..892374e275bd --- /dev/null +++ b/test/message/vm_syntax_error.out @@ -0,0 +1,6 @@ +bar:1 +invalid ?= 1 + ^ +SyntaxError: Unexpected token = + at context.run (*test*message*vm_syntax_error.js:*:*) + at foo:1:1