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

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/private/js_helper.dart

Issue 2869463002: Better stack trace support (Closed)
Patch Set: some more fixes Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart._js_helper; 5 library dart._js_helper;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'dart:_debugger' show stackTraceMapper; 9 import 'dart:_debugger' show stackTraceMapper;
10 10
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 } 486 }
487 487
488 static void setProperty(object, key, value) { 488 static void setProperty(object, key, value) {
489 if (object == null || object is bool || object is num || object is String) { 489 if (object == null || object is bool || object is num || object is String) {
490 throw argumentErrorValue(object); 490 throw argumentErrorValue(object);
491 } 491 }
492 JS('void', '#[#] = #', object, key, value); 492 JS('void', '#[#] = #', object, key, value);
493 } 493 }
494 494
495 static StackTrace extractStackTrace(Error error) { 495 static StackTrace extractStackTrace(Error error) {
496 return getTraceFromException(JS('', r'#.$thrownJsError', error)); 496 return JS('StackTrace', 'dart.stackTrace(#)', error);
Jennifer Messerly 2017/05/05 23:59:15 question ... i've seen this pattern too in dart:mi
vsm 2017/05/08 17:07:44 Oh nice - the typed call works! In this case th
497 } 497 }
498 } 498 }
499 499
500 /** 500 /**
501 * Diagnoses an indexing error. Returns the ArgumentError or RangeError that 501 * Diagnoses an indexing error. Returns the ArgumentError or RangeError that
502 * describes the problem. 502 * describes the problem.
503 */ 503 */
504 @NoInline() 504 @NoInline()
505 Error diagnoseIndexError(indexable, index) { 505 Error diagnoseIndexError(indexable, index) {
506 if (index is! int) return new ArgumentError.value(index, 'index'); 506 if (index is! int) return new ArgumentError.value(index, 'index');
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 620
621 class UnknownJsTypeError extends Error { 621 class UnknownJsTypeError extends Error {
622 final String _message; 622 final String _message;
623 623
624 UnknownJsTypeError(this._message); 624 UnknownJsTypeError(this._message);
625 625
626 String toString() => _message.isEmpty ? 'Error' : 'Error: $_message'; 626 String toString() => _message.isEmpty ? 'Error' : 'Error: $_message';
627 } 627 }
628 628
629 /** 629 /**
630 * Called by generated code to fetch the stack trace from an 630 * Called by generated code to fetch the stack trace from a Dart
631 * exception. Should never return null. 631 * exception. Should never return null.
632 */ 632 */
633 StackTrace getTraceFromException(exception) => new _StackTrace(exception); 633 final _stackTrace = JS('', 'Symbol("_stackTrace")');
634 StackTrace getTraceFromException(exception) {
635 var error = JS('', 'dart.recordJsError(#)', exception);
Jennifer Messerly 2017/05/05 23:59:15 same as above, I don't think we need to use JS cod
636 var trace = JS('StackTrace', '#[#]', error, _stackTrace);
637 if (trace != null) return trace;
638 trace = new _StackTrace(error);
639 JS('', '#[#] = #', error, _stackTrace, trace);
640 return trace;
641 }
642
643 //=> JS('StackTrace', 'dart.stackTrace(#)', exception);
Jennifer Messerly 2017/05/05 23:59:15 remove this comment?
vsm 2017/05/08 17:07:44 doh!
634 644
635 class _StackTrace implements StackTrace { 645 class _StackTrace implements StackTrace {
636 var _exception; 646 var _exception;
637 String _trace; 647 String _trace;
638 648
639 _StackTrace(this._exception); 649 _StackTrace(this._exception);
640 650
641 String toString() { 651 String toString() {
642 if (_trace != null) return _trace; 652 if (_trace != null) return _trace;
643 653
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 // we have no way of telling the compiler yet, so it will generate an extra 926 // we have no way of telling the compiler yet, so it will generate an extra
917 // layer of indirection that wraps the SyncIterator. 927 // layer of indirection that wraps the SyncIterator.
918 _jsIterator() => JS('', '#(...#)', _generator, _args); 928 _jsIterator() => JS('', '#(...#)', _generator, _args);
919 929
920 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); 930 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator());
921 } 931 }
922 932
923 class BooleanConversionAssertionError extends AssertionError { 933 class BooleanConversionAssertionError extends AssertionError {
924 toString() => 'Failed assertion: boolean expression must not be null'; 934 toString() => 'Failed assertion: boolean expression must not be null';
925 } 935 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698