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

Side by Side Diff: runtime/lib/errors_patch.dart

Issue 1778133002: Enumerate URIs of all types in type errors in order to help the user diagnose (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 4 years, 9 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
« no previous file with comments | « runtime/lib/errors.cc ('k') | runtime/lib/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import 'dart:_internal' as internal; 5 import 'dart:_internal' as internal;
6 import 'dart:convert' show JSON; 6 import 'dart:convert' show JSON;
7 7
8 patch class Error { 8 patch class Error {
9 /* patch */ static String _objectToString(Object object) { 9 /* patch */ static String _objectToString(Object object) {
10 return Object._toString(object); 10 return Object._toString(object);
(...skipping 27 matching lines...) Expand all
38 return "'$_url': Failed assertion: line $_line$columnInfo: " 38 return "'$_url': Failed assertion: line $_line$columnInfo: "
39 "'$_failedAssertion' is not true."; 39 "'$_failedAssertion' is not true.";
40 } 40 }
41 final String _failedAssertion; 41 final String _failedAssertion;
42 final String _url; 42 final String _url;
43 final int _line; 43 final int _line;
44 final int _column; 44 final int _column;
45 } 45 }
46 46
47 class _TypeError extends _AssertionError implements TypeError { 47 class _TypeError extends _AssertionError implements TypeError {
48 _TypeError._create(String url, int line, int column, 48 _TypeError._create(String url, int line, int column, this._errorMsg)
49 this._srcType, this._dstType, this._dstName,
50 this._errorMsg)
51 : super._create("is assignable", url, line, column); 49 : super._create("is assignable", url, line, column);
52 50
53 static _throwNew(int location, 51 static _throwNew(int location,
54 Object src_value, 52 Object src_value,
55 String dst_type_name, 53 _Type dst_type,
56 String dst_name, 54 String dst_name,
57 String error_msg) 55 String bound_error_msg)
58 native "TypeError_throwNew"; 56 native "TypeError_throwNew";
59 57
60 static _throwNewIfNotLoaded(_LibraryPrefix prefix, 58 static _throwNewIfNotLoaded(_LibraryPrefix prefix,
61 int location, 59 int location,
62 Object src_value, 60 Object src_value,
63 String dst_type_name, 61 _Type dst_type,
64 String dst_name, 62 String dst_name,
65 String error_msg) { 63 String bound_error_msg) {
66 if (!prefix.isLoaded()) { 64 if (!prefix.isLoaded()) {
67 _throwNew(location, src_value, dst_type_name, dst_name, error_msg); 65 _throwNew(location, src_value, dst_type, dst_name, bound_error_msg);
68 } 66 }
69 } 67 }
70 68
69 String toString() => _errorMsg;
71 70
72 String toString() {
73 String str = (_errorMsg != null) ? _errorMsg : "";
74 if ((_dstName != null) && (_dstName.length > 0)) {
75 str = "${str}type '$_srcType' is not a subtype of "
76 "type '$_dstType' of '$_dstName'.";
77 } else {
78 str = "${str}type error.";
79 }
80 return str;
81 }
82
83 final String _srcType;
84 final String _dstType;
85 final String _dstName;
86 final String _errorMsg; 71 final String _errorMsg;
87 } 72 }
88 73
89 class _CastError extends Error implements CastError { 74 class _CastError extends Error implements CastError {
90 _CastError._create(this._url, this._line, this._column, 75 _CastError._create(this._url, this._line, this._column, this._errorMsg);
91 this._srcType, this._dstType, this._dstName,
92 this._errorMsg);
93 76
94 // A CastError is allocated by TypeError._throwNew() when dst_name equals 77 // A CastError is allocated by TypeError._throwNew() when dst_name equals
95 // Exceptions::kCastErrorDstName. 78 // Symbols::InTypeCast().
96 79
97 String toString() { 80 String toString() => _errorMsg;
98 String str = (_errorMsg != null) ? _errorMsg : "";
99 str = "${str}type '$_srcType' is not a subtype of "
100 "type '$_dstType' in type cast.";
101 return str;
102 }
103 81
104 // Fields _url, _line, and _column are only used for debugging purposes. 82 // Fields _url, _line, and _column are only used for debugging purposes.
105 final String _url; 83 final String _url;
106 final int _line; 84 final int _line;
107 final int _column; 85 final int _column;
108 final String _srcType;
109 final String _dstType;
110 final String _dstName;
111 final String _errorMsg; 86 final String _errorMsg;
112 } 87 }
113 88
114 patch class FallThroughError { 89 patch class FallThroughError {
115 FallThroughError._create(this._url, this._line); 90 FallThroughError._create(this._url, this._line);
116 91
117 static _throwNew(int case_clause_pos) native "FallThroughError_throwNew"; 92 static _throwNew(int case_clause_pos) native "FallThroughError_throwNew";
118 93
119 /* patch */ String toString() { 94 /* patch */ String toString() {
120 return "'$_url': Switch case fall-through at line $_line."; 95 return "'$_url': Switch case fall-through at line $_line.";
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 msg_buf.write( 330 msg_buf.write(
356 "NoSuchMethodError: incorrect number of arguments passed to " 331 "NoSuchMethodError: incorrect number of arguments passed to "
357 "method named '$memberName'\n" 332 "method named '$memberName'\n"
358 "Receiver: $receiver_str\n" 333 "Receiver: $receiver_str\n"
359 "Tried calling: $memberName($actualParameters)\n" 334 "Tried calling: $memberName($actualParameters)\n"
360 "Found: $memberName($formalParameters)"); 335 "Found: $memberName($formalParameters)");
361 } 336 }
362 return msg_buf.toString(); 337 return msg_buf.toString();
363 } 338 }
364 } 339 }
OLDNEW
« no previous file with comments | « runtime/lib/errors.cc ('k') | runtime/lib/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698