Chromium Code Reviews| Index: runtime/lib/errors_patch.dart |
| diff --git a/runtime/lib/errors_patch.dart b/runtime/lib/errors_patch.dart |
| index 26358027749c23366f3d179cda7675cbd548186e..6bd0881471a5043718aab09c049ae6685d6ec832 100644 |
| --- a/runtime/lib/errors_patch.dart |
| +++ b/runtime/lib/errors_patch.dart |
| @@ -18,29 +18,37 @@ |
| 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) |
| - native "AssertionError_throwNew"; |
| - static void _checkAssertion(condition, int start, int end) { |
| + // AssertionError_throwNew in errors.cc fishes the assertion source code |
| + // out of the script. It expects a Dart stack frame from class |
| + // _AssertionError. Thus we need a Dart stub that calls the native code. |
| + static _throwNew(int assertionStart, int assertionEnd, Object message) { |
|
hausner
2016/12/14 18:30:24
Turns out the indirection through a Dart method is
Lasse Reichstein Nielsen
2016/12/14 20:47:18
Yes, I don't know why, but I couldn't get it worki
|
| + _doThrowNew(assertionStart, assertionEnd, message); |
| + } |
| + |
| + static _doThrowNew(int assertionStart, int assertionEnd, Object message) |
| + native "AssertionError_throwNew"; |
| + |
| + static _evaluateAssertion(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 +56,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 +87,7 @@ class _TypeError extends _AssertionError implements TypeError { |
| } |
| } |
| - String toString() => _errorMsg; |
| - |
| - final String _errorMsg; |
| + String toString() => super.message; |
| } |
| class _CastError extends Error implements CastError { |