| OLD | NEW |
| 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 class Error { | 5 class Error { |
| 6 const Error(); | 6 const Error(); |
| 7 } | 7 } |
| 8 | 8 |
| 9 class AssertionError implements Error { | 9 class AssertionError implements Error { |
| 10 } | 10 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 String formalParameters = sb.toString(); | 75 String formalParameters = sb.toString(); |
| 76 return "NoSuchMethodError: incorrect number of arguments passed to " | 76 return "NoSuchMethodError: incorrect number of arguments passed to " |
| 77 "method named '$_functionName'\n" | 77 "method named '$_functionName'\n" |
| 78 "Receiver: ${safeToString(_receiver)}\n" | 78 "Receiver: ${safeToString(_receiver)}\n" |
| 79 "Tried calling: $_functionName($actualParameters)\n" | 79 "Tried calling: $_functionName($actualParameters)\n" |
| 80 "Found: $_functionName($formalParameters)"; | 80 "Found: $_functionName($formalParameters)"; |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 external static String safeToString(Object object); | 84 static String safeToString(Object object) { |
| 85 if (object is int || object is double || object is bool || null == object) { |
| 86 return object.toString(); |
| 87 } |
| 88 if (object is String) { |
| 89 // TODO(ahe): Remove backslash when http://dartbug.com/4995 is fixed. |
| 90 const backslash = '\\'; |
| 91 String escaped = object |
| 92 .replaceAll('$backslash', '$backslash$backslash') |
| 93 .replaceAll('\n', '${backslash}n') |
| 94 .replaceAll('\r', '${backslash}r') |
| 95 .replaceAll('"', '$backslash"'); |
| 96 return '"$escaped"'; |
| 97 } |
| 98 return _objectToString(object); |
| 99 } |
| 100 |
| 101 external static _objectToString(Object object); |
| 85 } | 102 } |
| OLD | NEW |