Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: src/d8.cc

Issue 2069543007: [d8] Make exception reporting more resilient. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-620253.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 8c0f82a3117245f0e6e6a1202db20553d3de111b..cc62aa8cb6acdcadda0a1dbc29ee2109d0b2b97b 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -925,25 +925,28 @@ void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) {
// Print (filename):(line number): (message).
v8::String::Utf8Value filename(message->GetScriptOrigin().ResourceName());
const char* filename_string = ToCString(filename);
- int linenum =
- message->GetLineNumber(isolate->GetCurrentContext()).FromJust();
+ Maybe<int> maybeline = message->GetLineNumber(isolate->GetCurrentContext());
+ int linenum = maybeline.IsJust() ? maybeline.FromJust() : -1;
printf("%s:%i: %s\n", filename_string, linenum, exception_string);
- // Print line of source code.
- v8::String::Utf8Value sourceline(
- message->GetSourceLine(isolate->GetCurrentContext()).ToLocalChecked());
- const char* sourceline_string = ToCString(sourceline);
- printf("%s\n", sourceline_string);
- // Print wavy underline (GetUnderline is deprecated).
- int start =
- message->GetStartColumn(isolate->GetCurrentContext()).FromJust();
- for (int i = 0; i < start; i++) {
- printf(" ");
- }
- int end = message->GetEndColumn(isolate->GetCurrentContext()).FromJust();
- for (int i = start; i < end; i++) {
- printf("^");
+ if (maybeline.IsJust()) {
+ // Print line of source code.
+ v8::String::Utf8Value sourceline(
+ message->GetSourceLine(isolate->GetCurrentContext())
+ .ToLocalChecked());
+ const char* sourceline_string = ToCString(sourceline);
+ printf("%s\n", sourceline_string);
+ // Print wavy underline (GetUnderline is deprecated).
+ int start =
+ message->GetStartColumn(isolate->GetCurrentContext()).FromJust();
+ for (int i = 0; i < start; i++) {
+ printf(" ");
+ }
+ int end = message->GetEndColumn(isolate->GetCurrentContext()).FromJust();
+ for (int i = start; i < end; i++) {
+ printf("^");
+ }
+ printf("\n");
}
- printf("\n");
Local<Value> stack_trace_string;
if (try_catch->StackTrace(isolate->GetCurrentContext())
.ToLocal(&stack_trace_string) &&
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-620253.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698