Skip to content
Browse files

Removed try/catch from v8.compileFile() altogether.

Compile error is caught by uncaught error handler.

User may try/catch and do whatever around v8.compileFile().

Note: compileFile is called by require() and include()
  • Loading branch information...
1 parent c3906bb commit fdf5720efc248b2e4aabd562b10b575a40c9f181 @mschwartz committed
Showing with 24 additions and 23 deletions.
  1. +9 −9 builtin/require.js
  2. +15 −14 src/v8.cpp
View
18 builtin/require.js
@@ -8,21 +8,21 @@
var console = builtin.console;
function runScript(src, fn) {
- try {
+// try {
var script = v8.compileScript(src, fn);
var exports = v8.runScript(script);
v8.freeScript(script);
return exports;
- }
- catch (e) {
- console.log(e);
- if (e.stack) {
- console.log(e.stack);
- }
- throw new Error('require failed due to compile errors');
+// }
+// catch (e) {
+// console.log(e);
+// if (e.stack) {
+// console.log(e.stack);
+// }
+// throw new Error('require failed due to compile errors');
// console.log(builtin.print_r(e));
// builtin.process.exit(1);
- }
+// }
}
function locateFile(module) {
function tryFile(path) {
View
29 src/v8.cpp
@@ -56,23 +56,24 @@ static JSVAL gc (const Arguments& args) {
static JSVAL compileScript (JSARGS args) {
// Persistent<Context>context = Context::New(NULL, ObjectTemplate::New());
// Context::Scope context_scope(context);
- TryCatch tryCatch;
+// TryCatch tryCatch;
Persistent<Script>s = Persistent<Script>::New(Script::New(args[0]->ToString(), args[1]->ToString()));
if (s.IsEmpty()) {
- String::Utf8Value error(tryCatch.Exception());
- Handle<Message>message = tryCatch.Message();
- if (message.IsEmpty()) {
- return ThrowException(String::New(*error)); // String::Concat(String::New("Error compiling "), args[1]->ToString()));
- }
- else {
- String::Utf8Value filename(message->GetScriptResourceName());
- int lineNumber = message->GetLineNumber();
- char buf[512];
- sprintf(buf, "Error in %s:%d (%s)", *filename, lineNumber, *error);
- return ThrowException(String::New(buf));
- }
+// String::Utf8Value error(tryCatch.Exception());
+// Handle<Message>message = tryCatch.Message();
+// if (message.IsEmpty()) {
+// return ThrowException(String::New(*error)); // String::Concat(String::New("Error compiling "), args[1]->ToString()));
+// }
+// else {
+// String::Utf8Value filename(message->GetScriptResourceName());
+// int lineNumber = message->GetLineNumber();
+// char buf[512];
+// sprintf(buf, "Error in %s:%d (%s)", *filename, lineNumber, *error);
+// return ThrowException(String::New(buf));
+// }
// delete wrapper;
- // return Opaque::New(NULL);
+// return Opaque::New(NULL);
+ return Null();
}
ScriptWrapper *wrapper = new ScriptWrapper;
wrapper->script = s; // Persistent<Script>::New(Script::New(args[0]->ToString(), args[1]->ToString()));

0 comments on commit fdf5720

Please sign in to comment.
Something went wrong with that request. Please try again.