| Index: dart/lib/core/errors.dart
|
| diff --git a/dart/lib/core/errors.dart b/dart/lib/core/errors.dart
|
| index 2c904587e225ccc233eccfeadb2c8597e19c2cf5..659810714f30d829a97fc67b27794ca590067029 100644
|
| --- a/dart/lib/core/errors.dart
|
| +++ b/dart/lib/core/errors.dart
|
| @@ -81,5 +81,22 @@ class NoSuchMethodError implements Error {
|
| }
|
| }
|
|
|
| - external static String safeToString(Object object);
|
| + static String safeToString(Object object) {
|
| + if (object is int || object is double || object is bool || null == object) {
|
| + return object.toString();
|
| + }
|
| + if (object is String) {
|
| + // TODO(ahe): Remove backslash when http://dartbug.com/4995 is fixed.
|
| + const backslash = '\\';
|
| + String escaped = object
|
| + .replaceAll('$backslash', '$backslash$backslash')
|
| + .replaceAll('\n', '${backslash}n')
|
| + .replaceAll('\r', '${backslash}r')
|
| + .replaceAll('"', '$backslash"');
|
| + return '"$escaped"';
|
| + }
|
| + return _objectToString(object);
|
| + }
|
| +
|
| + external static _objectToString(Object object);
|
| }
|
|
|