Skip to content

Commit 78be1e4

Browse files
isaacsry
authored andcommitted
Remove the ReportException from the Script class
This is so that syntax errors can be handled discretely in places like the repl, where SyntaxErrors are expected and normal.
1 parent d8af9d8 commit 78be1e4

1 file changed

Lines changed: 0 additions & 48 deletions

File tree

src/node_script.cc

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -79,53 +79,6 @@ const char* ToCString(const v8::String::Utf8Value& value) {
7979
return *value ? *value : "<str conversion failed>";
8080
}
8181

82-
83-
static void ReportException(TryCatch &try_catch, bool show_line = false, bool show_rest = true) {
84-
Handle<Message> message = try_catch.Message();
85-
86-
Handle<Value> error = try_catch.Exception();
87-
Handle<String> stack;
88-
89-
if (error->IsObject()) {
90-
Handle<Object> obj = Handle<Object>::Cast(error);
91-
Handle<Value> raw_stack = obj->Get(String::New("stack"));
92-
if (raw_stack->IsString()) stack = Handle<String>::Cast(raw_stack);
93-
}
94-
95-
if (show_line && !message.IsEmpty()) {
96-
// Print (filename):(line number): (message).
97-
String::Utf8Value filename(message->GetScriptResourceName());
98-
const char* filename_string = ToCString(filename);
99-
int linenum = message->GetLineNumber();
100-
fprintf(stderr, "%s:%i\n", filename_string, linenum);
101-
// Print line of source code.
102-
String::Utf8Value sourceline(message->GetSourceLine());
103-
const char* sourceline_string = ToCString(sourceline);
104-
fprintf(stderr, "%s\n", sourceline_string);
105-
// Print wavy underline (GetUnderline is deprecated).
106-
int start = message->GetStartColumn();
107-
for (int i = 0; i < start; i++) {
108-
fprintf(stderr, " ");
109-
}
110-
int end = message->GetEndColumn();
111-
for (int i = start; i < end; i++) {
112-
fprintf(stderr, "^");
113-
}
114-
fprintf(stderr, "\n");
115-
}
116-
117-
if (show_rest) {
118-
if (stack.IsEmpty()) {
119-
message->PrintCurrentStackTrace(stderr);
120-
} else {
121-
String::Utf8Value trace(stack);
122-
fprintf(stderr, "%s\n", *trace);
123-
}
124-
}
125-
fflush(stderr);
126-
}
127-
128-
12982
template <node::Script::EvalInputFlags iFlag,
13083
node::Script::EvalContextFlags cFlag,
13184
node::Script::EvalOutputFlags oFlag>
@@ -181,7 +134,6 @@ Handle<Value> node::Script::EvalMachine(const Arguments& args) {
181134
script = oFlag == returnResult ? v8::Script::Compile(code, filename) : v8::Script::New(code, filename);
182135
if (script.IsEmpty()) {
183136
// Hack because I can't get a proper stacktrace on SyntaxError
184-
ReportException(try_catch, true, false);
185137
result = ThrowException(try_catch.Exception());
186138
}
187139
} else {

0 commit comments

Comments
 (0)