Revision 408526a1 src/node.cc
src/node.cc | ||
---|---|---|
70 | 70 |
v8::Handle<v8::Value> filename) |
71 | 71 |
{ |
72 | 72 |
HandleScope scope; |
73 |
TryCatch try_catch; |
|
74 |
|
|
73 | 75 |
Handle<Script> script = Script::Compile(source, filename); |
74 | 76 |
if (script.IsEmpty()) { |
75 |
return ThrowException(String::New("Error compiling string")); |
|
77 |
ReportException(&try_catch); |
|
78 |
exit(1); |
|
76 | 79 |
} |
77 | 80 |
|
78 | 81 |
Handle<Value> result = script->Run(); |
79 | 82 |
if (result.IsEmpty()) { |
80 |
return ThrowException(String::New("Error running string")); |
|
83 |
ReportException(&try_catch); |
|
84 |
exit(1); |
|
81 | 85 |
} |
82 | 86 |
|
83 | 87 |
return scope.Close(result); |
... | ... | |
98 | 102 |
return scope.Close(result); |
99 | 103 |
} |
100 | 104 |
|
105 |
JS_METHOD(debug) |
|
106 |
{ |
|
107 |
if (args.Length() < 1) |
|
108 |
return Undefined(); |
|
109 |
HandleScope scope; |
|
110 |
String::Utf8Value msg(args[0]->ToString()); |
|
111 |
fprintf(stderr, "DEBUG: %s\n", *msg); |
|
112 |
return Undefined(); |
|
113 |
} |
|
101 | 114 |
|
102 | 115 |
static void |
103 | 116 |
OnFatalError (const char* location, const char* message) |
... | ... | |
182 | 195 |
g->Set(String::New("node"), node); |
183 | 196 |
|
184 | 197 |
JS_SET_METHOD(node, "compile", compile); |
198 |
JS_SET_METHOD(node, "debug", debug); |
|
185 | 199 |
|
186 | 200 |
Local<Array> arguments = Array::New(argc); |
187 | 201 |
for (int i = 0; i < argc; i++) { |
Also available in: Unified diff