| 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 class Error { | 7 class Error { |
| 8 /** | 8 /** |
| 9 * Safely convert a value to a [String] description. | 9 * Safely convert a value to a [String] description. |
| 10 * | 10 * |
| 11 * The conversion is guaranteed to not throw, so it won't use the object's | 11 * The conversion is guaranteed to not throw, so it won't use the object's |
| 12 * toString method. | 12 * toString method. |
| 13 */ | 13 */ |
| 14 static String safeToString(Object object) { | 14 static String safeToString(Object object) { |
| 15 if (object is int || object is double || object is bool || null == object) { | 15 if (object is num || object is bool || null == object) { |
| 16 return object.toString(); | 16 return object.toString(); |
| 17 } | 17 } |
| 18 if (object is String) { | 18 if (object is String) { |
| 19 String string = object; | 19 String string = object; |
| 20 StringBuffer buffer = new StringBuffer('"'); | 20 StringBuffer buffer = new StringBuffer('"'); |
| 21 const int TAB = 0x09; | 21 const int TAB = 0x09; |
| 22 const int NEWLINE = 0x0a; | 22 const int NEWLINE = 0x0a; |
| 23 const int CARRIGE_RETURN = 0x0d; | 23 const int CARRIGE_RETURN = 0x0d; |
| 24 const int BACKSLASH = 0x5c; | 24 const int BACKSLASH = 0x5c; |
| 25 const int DOUBLE_QUOTE = 0x22; | 25 const int DOUBLE_QUOTE = 0x22; |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 * the first time it is read. If evaluating the initializer expression causes | 293 * the first time it is read. If evaluating the initializer expression causes |
| 294 * another read of the variable, this error is thrown. | 294 * another read of the variable, this error is thrown. |
| 295 */ | 295 */ |
| 296 class CyclicInitializationError extends Error { | 296 class CyclicInitializationError extends Error { |
| 297 final String variableName; | 297 final String variableName; |
| 298 CyclicInitializationError([this.variableName]); | 298 CyclicInitializationError([this.variableName]); |
| 299 String toString() => variableName == null | 299 String toString() => variableName == null |
| 300 ? "Reading static variable during its initialization" | 300 ? "Reading static variable during its initialization" |
| 301 : "Reading static variable '$variableName' during its initialization"; | 301 : "Reading static variable '$variableName' during its initialization"; |
| 302 } | 302 } |
| OLD | NEW |