Chromium Code Reviews| Index: runtime/lib/errors_patch.dart |
| diff --git a/runtime/lib/errors_patch.dart b/runtime/lib/errors_patch.dart |
| index 59a61ec4bb9238f98da38db0bd605b63a7c3c224..715720d002b3eac1a436afb1048e0942df4bc1e5 100644 |
| --- a/runtime/lib/errors_patch.dart |
| +++ b/runtime/lib/errors_patch.dart |
| @@ -21,14 +21,22 @@ patch class Error { |
| class _AssertionError extends Error implements AssertionError { |
| _AssertionError._create( |
| - this._failedAssertion, this._url, this._line, this._column); |
| + this._failedAssertion, this._url, this._line, this._column, |
| + this.message); |
| - static _throwNew(int assertionStart, int assertionEnd) |
| + static _throwNew(int assertionStart, int assertionEnd, Object message) |
| native "AssertionError_throwNew"; |
| + String get _messageString { |
| + if (message == null) return "is not true."; |
| + if (message is String) return message; |
| + return Error.safeToString(message); |
| + } |
| + |
| String toString() { |
| if (_url == null) { |
| - return _failedAssertion; |
| + if (message == null) return _failedAssertion; |
| + return "'$_failedAssertion' $_messageString"; |
| } |
| var columnInfo = ""; |
| if (_column > 0) { |
| @@ -36,19 +44,20 @@ class _AssertionError extends Error implements AssertionError { |
| columnInfo = " pos $_column"; |
| } |
| return "'$_url': Failed assertion: line $_line$columnInfo: " |
| - "'$_failedAssertion' is not true."; |
| + "'$_failedAssertion' $_messageString"; |
|
Lasse Reichstein Nielsen
2015/08/28 18:51:59
The format is negotiable.
|
| } |
| final String _failedAssertion; |
| final String _url; |
| final int _line; |
| final int _column; |
| + final Object message; |
| } |
| class _TypeError extends _AssertionError implements TypeError { |
| _TypeError._create(String url, int line, int column, |
| this._srcType, this._dstType, this._dstName, |
| - this._errorMsg) |
| - : super._create("is assignable", url, line, column); |
| + String error_msg) |
| + : super._create("is assignable", url, line, column, error_msg); |
| static _throwNew(int location, |
| Object src_value, |
| @@ -70,7 +79,7 @@ class _TypeError extends _AssertionError implements TypeError { |
| String toString() { |
| - String str = (_errorMsg != null) ? _errorMsg : ""; |
| + String str = (message != null) ? message : ""; |
| if ((_dstName != null) && (_dstName.length > 0)) { |
| str = "${str}type '$_srcType' is not a subtype of " |
| "type '$_dstType' of '$_dstName'."; |
| @@ -83,7 +92,6 @@ class _TypeError extends _AssertionError implements TypeError { |
| final String _srcType; |
| final String _dstType; |
| final String _dstName; |
| - final String _errorMsg; |
| } |
| class _CastError extends Error implements CastError { |