OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 v8::HandleScope handle_scope(isolate); | 293 v8::HandleScope handle_scope(isolate); |
294 v8::String::Utf8Value exception(try_catch->Exception()); | 294 v8::String::Utf8Value exception(try_catch->Exception()); |
295 const char* exception_string = ToCString(exception); | 295 const char* exception_string = ToCString(exception); |
296 v8::Handle<v8::Message> message = try_catch->Message(); | 296 v8::Handle<v8::Message> message = try_catch->Message(); |
297 if (message.IsEmpty()) { | 297 if (message.IsEmpty()) { |
298 // V8 didn't provide any extra information about this error; just | 298 // V8 didn't provide any extra information about this error; just |
299 // print the exception. | 299 // print the exception. |
300 printf("%s\n", exception_string); | 300 printf("%s\n", exception_string); |
301 } else { | 301 } else { |
302 // Print (filename):(line number): (message). | 302 // Print (filename):(line number): (message). |
303 v8::String::Utf8Value filename(message->GetScriptResourceName()); | 303 v8::String::Utf8Value filename(message->GetScriptOrigin().ResourceName()); |
304 const char* filename_string = ToCString(filename); | 304 const char* filename_string = ToCString(filename); |
305 int linenum = message->GetLineNumber(); | 305 int linenum = message->GetLineNumber(); |
306 printf("%s:%i: %s\n", filename_string, linenum, exception_string); | 306 printf("%s:%i: %s\n", filename_string, linenum, exception_string); |
307 // Print line of source code. | 307 // Print line of source code. |
308 v8::String::Utf8Value sourceline(message->GetSourceLine()); | 308 v8::String::Utf8Value sourceline(message->GetSourceLine()); |
309 const char* sourceline_string = ToCString(sourceline); | 309 const char* sourceline_string = ToCString(sourceline); |
310 printf("%s\n", sourceline_string); | 310 printf("%s\n", sourceline_string); |
311 // Print wavy underline (GetUnderline is deprecated). | 311 // Print wavy underline (GetUnderline is deprecated). |
312 int start = message->GetStartColumn(); | 312 int start = message->GetStartColumn(); |
313 for (int i = 0; i < start; i++) { | 313 for (int i = 0; i < start; i++) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 } | 370 } |
371 // Remove newline char | 371 // Remove newline char |
372 for (char* pos = buffer; *pos != '\0'; pos++) { | 372 for (char* pos = buffer; *pos != '\0'; pos++) { |
373 if (*pos == '\n') { | 373 if (*pos == '\n') { |
374 *pos = '\0'; | 374 *pos = '\0'; |
375 break; | 375 break; |
376 } | 376 } |
377 } | 377 } |
378 return v8::String::NewFromUtf8(isolate, buffer); | 378 return v8::String::NewFromUtf8(isolate, buffer); |
379 } | 379 } |
OLD | NEW |