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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 v8::HandleScope handle_scope(isolate); | 351 v8::HandleScope handle_scope(isolate); |
352 v8::String::Utf8Value exception(try_catch->Exception()); | 352 v8::String::Utf8Value exception(try_catch->Exception()); |
353 const char* exception_string = ToCString(exception); | 353 const char* exception_string = ToCString(exception); |
354 v8::Handle<v8::Message> message = try_catch->Message(); | 354 v8::Handle<v8::Message> message = try_catch->Message(); |
355 if (message.IsEmpty()) { | 355 if (message.IsEmpty()) { |
356 // V8 didn't provide any extra information about this error; just | 356 // V8 didn't provide any extra information about this error; just |
357 // print the exception. | 357 // print the exception. |
358 fprintf(stderr, "%s\n", exception_string); | 358 fprintf(stderr, "%s\n", exception_string); |
359 } else { | 359 } else { |
360 // Print (filename):(line number): (message). | 360 // Print (filename):(line number): (message). |
361 v8::String::Utf8Value filename(message->GetScriptResourceName()); | 361 v8::String::Utf8Value filename(message->GetScriptOrigin().ResourceName()); |
362 const char* filename_string = ToCString(filename); | 362 const char* filename_string = ToCString(filename); |
363 int linenum = message->GetLineNumber(); | 363 int linenum = message->GetLineNumber(); |
364 fprintf(stderr, "%s:%i: %s\n", filename_string, linenum, exception_string); | 364 fprintf(stderr, "%s:%i: %s\n", filename_string, linenum, exception_string); |
365 // Print line of source code. | 365 // Print line of source code. |
366 v8::String::Utf8Value sourceline(message->GetSourceLine()); | 366 v8::String::Utf8Value sourceline(message->GetSourceLine()); |
367 const char* sourceline_string = ToCString(sourceline); | 367 const char* sourceline_string = ToCString(sourceline); |
368 fprintf(stderr, "%s\n", sourceline_string); | 368 fprintf(stderr, "%s\n", sourceline_string); |
369 // Print wavy underline (GetUnderline is deprecated). | 369 // Print wavy underline (GetUnderline is deprecated). |
370 int start = message->GetStartColumn(); | 370 int start = message->GetStartColumn(); |
371 for (int i = 0; i < start; i++) { | 371 for (int i = 0; i < start; i++) { |
372 fprintf(stderr, " "); | 372 fprintf(stderr, " "); |
373 } | 373 } |
374 int end = message->GetEndColumn(); | 374 int end = message->GetEndColumn(); |
375 for (int i = start; i < end; i++) { | 375 for (int i = start; i < end; i++) { |
376 fprintf(stderr, "^"); | 376 fprintf(stderr, "^"); |
377 } | 377 } |
378 fprintf(stderr, "\n"); | 378 fprintf(stderr, "\n"); |
379 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); | 379 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); |
380 if (stack_trace.length() > 0) { | 380 if (stack_trace.length() > 0) { |
381 const char* stack_trace_string = ToCString(stack_trace); | 381 const char* stack_trace_string = ToCString(stack_trace); |
382 fprintf(stderr, "%s\n", stack_trace_string); | 382 fprintf(stderr, "%s\n", stack_trace_string); |
383 } | 383 } |
384 } | 384 } |
385 } | 385 } |
OLD | NEW |