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

Side by Side Diff: src/isolate.cc

Issue 1507273002: Make Error.prototype.toString spec compliant; and fix various side-effect-free error printing metho… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/isolate.h" 5 #include "src/isolate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <fstream> // NOLINT(readability/streams) 9 #include <fstream> // NOLINT(readability/streams)
10 #include <sstream> 10 #include <sstream>
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 int pos = PositionFromStackTrace(elements, i); 1341 int pos = PositionFromStackTrace(elements, i);
1342 Handle<Script> casted_script(Script::cast(script)); 1342 Handle<Script> casted_script(Script::cast(script));
1343 *target = MessageLocation(casted_script, pos, pos + 1); 1343 *target = MessageLocation(casted_script, pos, pos + 1);
1344 return true; 1344 return true;
1345 } 1345 }
1346 } 1346 }
1347 return false; 1347 return false;
1348 } 1348 }
1349 1349
1350 1350
1351 // Use stack_trace_symbol as proxy for [[ErrorData]].
1352 bool Isolate::IsErrorObject(Handle<Object> object) {
1353 Handle<Name> symbol = factory()->stack_trace_symbol();
1354 if (!object->IsJSObject()) return false;
1355 Maybe<bool> has_stack_trace =
1356 JSReceiver::HasOwnProperty(Handle<JSReceiver>::cast(object), symbol);
1357 DCHECK(!has_stack_trace.IsNothing());
1358 return has_stack_trace.FromJust();
1359 }
1360
1361
1362 Handle<JSMessageObject> Isolate::CreateMessage(Handle<Object> exception, 1351 Handle<JSMessageObject> Isolate::CreateMessage(Handle<Object> exception,
1363 MessageLocation* location) { 1352 MessageLocation* location) {
1364 Handle<JSArray> stack_trace_object; 1353 Handle<JSArray> stack_trace_object;
1365 if (capture_stack_trace_for_uncaught_exceptions_) { 1354 if (capture_stack_trace_for_uncaught_exceptions_) {
1366 if (IsErrorObject(exception)) { 1355 if (Object::IsErrorObject(this, exception)) {
1367 // We fetch the stack trace that corresponds to this error object. 1356 // We fetch the stack trace that corresponds to this error object.
1368 // If the lookup fails, the exception is probably not a valid Error 1357 // If the lookup fails, the exception is probably not a valid Error
1369 // object. In that case, we fall through and capture the stack trace 1358 // object. In that case, we fall through and capture the stack trace
1370 // at this throw site. 1359 // at this throw site.
1371 stack_trace_object = 1360 stack_trace_object =
1372 GetDetailedStackTrace(Handle<JSObject>::cast(exception)); 1361 GetDetailedStackTrace(Handle<JSObject>::cast(exception));
1373 } 1362 }
1374 if (stack_trace_object.is_null()) { 1363 if (stack_trace_object.is_null()) {
1375 // Not an error object, we capture stack and location at throw site. 1364 // Not an error object, we capture stack and location at throw site.
1376 stack_trace_object = CaptureCurrentStackTrace( 1365 stack_trace_object = CaptureCurrentStackTrace(
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after
2823 // Then check whether this scope intercepts. 2812 // Then check whether this scope intercepts.
2824 if ((flag & intercept_mask_)) { 2813 if ((flag & intercept_mask_)) {
2825 intercepted_flags_ |= flag; 2814 intercepted_flags_ |= flag;
2826 return true; 2815 return true;
2827 } 2816 }
2828 return false; 2817 return false;
2829 } 2818 }
2830 2819
2831 } // namespace internal 2820 } // namespace internal
2832 } // namespace v8 2821 } // namespace v8
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/js/messages.js » ('j') | src/messages.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698