| 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 part of dart.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Error objects thrown in the case of a program failure. | 8 * Error objects thrown in the case of a program failure. |
| 9 * | 9 * |
| 10 * An `Error` object represents a program failure that the programmer | 10 * An `Error` object represents a program failure that the programmer |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 static String safeToString(Object object) { | 77 static String safeToString(Object object) { |
| 78 if (object is num || object is bool || null == object) { | 78 if (object is num || object is bool || null == object) { |
| 79 return object.toString(); | 79 return object.toString(); |
| 80 } | 80 } |
| 81 if (object is String) { | 81 if (object is String) { |
| 82 return _stringToSafeString(object); | 82 return _stringToSafeString(object); |
| 83 } | 83 } |
| 84 return _objectToString(object); | 84 return _objectToString(object); |
| 85 } | 85 } |
| 86 | 86 |
| 87 @patch | 87 /** Convert string to a valid string literal with no control characters. */ |
| 88 static String _stringToSafeString(String string) { | 88 static String _stringToSafeString(String string) { |
| 89 return jsonEncodeNative(string); | 89 return jsonEncodeNative(string); |
| 90 } | 90 } |
| 91 | 91 |
| 92 @patch | |
| 93 static String _objectToString(Object object) { | 92 static String _objectToString(Object object) { |
| 94 return Primitives.objectToString(object); | 93 return Primitives.objectToString(object); |
| 95 } | 94 } |
| 96 | 95 |
| 97 @patch | |
| 98 StackTrace get stackTrace => Primitives.extractStackTrace(this); | 96 StackTrace get stackTrace => Primitives.extractStackTrace(this); |
| 99 } | 97 } |
| 100 | 98 |
| 101 /** | 99 /** |
| 102 * Error thrown by the runtime system when an assert statement fails. | 100 * Error thrown by the runtime system when an assert statement fails. |
| 103 */ | 101 */ |
| 104 class AssertionError extends Error { | 102 class AssertionError extends Error { |
| 105 } | 103 } |
| 106 | 104 |
| 107 /** | 105 /** |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 Symbol memberName, | 451 Symbol memberName, |
| 454 List positionalArguments, | 452 List positionalArguments, |
| 455 Map<Symbol ,dynamic> namedArguments, | 453 Map<Symbol ,dynamic> namedArguments, |
| 456 [List existingArgumentNames = null]) | 454 [List existingArgumentNames = null]) |
| 457 : _receiver = receiver, | 455 : _receiver = receiver, |
| 458 _memberName = memberName, | 456 _memberName = memberName, |
| 459 _arguments = positionalArguments, | 457 _arguments = positionalArguments, |
| 460 _namedArguments = namedArguments, | 458 _namedArguments = namedArguments, |
| 461 _existingArgumentNames = existingArgumentNames; | 459 _existingArgumentNames = existingArgumentNames; |
| 462 | 460 |
| 463 @patch | |
| 464 String toString() { | 461 String toString() { |
| 465 StringBuffer sb = new StringBuffer(); | 462 StringBuffer sb = new StringBuffer(); |
| 466 int i = 0; | 463 int i = 0; |
| 467 if (_arguments != null) { | 464 if (_arguments != null) { |
| 468 for (; i < _arguments.length; i++) { | 465 for (; i < _arguments.length; i++) { |
| 469 if (i > 0) { | 466 if (i > 0) { |
| 470 sb.write(", "); | 467 sb.write(", "); |
| 471 } | 468 } |
| 472 sb.write(Error.safeToString(_arguments[i])); | 469 sb.write(Error.safeToString(_arguments[i])); |
| 473 } | 470 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 * the first time it is read. If evaluating the initializer expression causes | 594 * the first time it is read. If evaluating the initializer expression causes |
| 598 * another read of the variable, this error is thrown. | 595 * another read of the variable, this error is thrown. |
| 599 */ | 596 */ |
| 600 class CyclicInitializationError extends Error { | 597 class CyclicInitializationError extends Error { |
| 601 final String variableName; | 598 final String variableName; |
| 602 CyclicInitializationError([this.variableName]); | 599 CyclicInitializationError([this.variableName]); |
| 603 String toString() => variableName == null | 600 String toString() => variableName == null |
| 604 ? "Reading static variable during its initialization" | 601 ? "Reading static variable during its initialization" |
| 605 : "Reading static variable '$variableName' during its initialization"; | 602 : "Reading static variable '$variableName' during its initialization"; |
| 606 } | 603 } |
| OLD | NEW |