Index: runtime/lib/errors_patch.dart |
diff --git a/runtime/lib/errors_patch.dart b/runtime/lib/errors_patch.dart |
index 26358027749c23366f3d179cda7675cbd548186e..1514c1f42a6a69dc026044aa7c6c13ac55d18913 100644 |
--- a/runtime/lib/errors_patch.dart |
+++ b/runtime/lib/errors_patch.dart |
@@ -18,29 +18,33 @@ |
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) { |
+ _doThrowNew(assertionStart, assertionEnd, message); |
+ } |
+ |
+ static _doThrowNew(int assertionStart, int assertionEnd, Object message) |
native "AssertionError_throwNew"; |
- static void _checkAssertion(condition, int start, int end) { |
+ static _checkAssertion(condition) { |
if (condition is Function) { |
condition = condition(); |
} |
- if (!condition) { |
- _throwNew(start, end); |
- } |
+ return condition; |
} |
- static void _checkConstAssertion(bool condition, int start, int end) { |
- if (!condition) { |
- _throwNew(start, end); |
- } |
+ 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) { |
@@ -48,17 +52,18 @@ class _AssertionError extends Error implements AssertionError { |
columnInfo = " pos $_column"; |
} |
return "'$_url': Failed assertion: line $_line$columnInfo: " |
- "'$_failedAssertion' is not true."; |
+ "'$_failedAssertion': $_messageString"; |
} |
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._errorMsg) |
- : super._create("is assignable", url, line, column); |
+ _TypeError._create(String url, int line, int column, String errorMsg) |
+ : super._create("is assignable", url, line, column, errorMsg); |
static _throwNew(int location, |
Object src_value, |
@@ -78,9 +83,7 @@ class _TypeError extends _AssertionError implements TypeError { |
} |
} |
- String toString() => _errorMsg; |
- |
- final String _errorMsg; |
+ String toString() => super.message; |
} |
class _CastError extends Error implements CastError { |