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 library dart.json; | 5 library dart.json; |
6 | 6 |
7 // JSON parsing and serialization. | 7 // JSON parsing and serialization. |
8 | 8 |
9 /** | 9 /** |
10 * Error thrown by JSON serialization if an object cannot be serialized. | 10 * Error thrown by JSON serialization if an object cannot be serialized. |
11 * | 11 * |
12 * The [unsupportedObject] field holds that object that failed to be serialized. | 12 * The [unsupportedObject] field holds that object that failed to be serialized. |
13 * | 13 * |
14 * If an object isn't directly serializable, the serializer calls the 'toJson' | 14 * If an object isn't directly serializable, the serializer calls the 'toJson' |
15 * method on the object. If that call fails, the error will be stored in the | 15 * method on the object. If that call fails, the error will be stored in the |
16 * [cause] field. If the call returns an object that isn't directly | 16 * [cause] field. If the call returns an object that isn't directly |
17 * serializable, the [cause] will be null. | 17 * serializable, the [cause] will be null. |
18 */ | 18 */ |
19 class JsonUnsupportedObjectError implements Error { | 19 class JsonUnsupportedObjectError extends Error { |
20 /** The object that could not be serialized. */ | 20 /** The object that could not be serialized. */ |
21 final unsupportedObject; | 21 final unsupportedObject; |
22 /** The exception thrown by object's [:toJson:] method, if any. */ | 22 /** The exception thrown by object's [:toJson:] method, if any. */ |
23 final cause; | 23 final cause; |
24 | 24 |
25 JsonUnsupportedObjectError(this.unsupportedObject, { this.cause }); | 25 JsonUnsupportedObjectError(this.unsupportedObject, { this.cause }); |
26 | 26 |
27 String toString() { | 27 String toString() { |
28 if (cause != null) { | 28 if (cause != null) { |
29 return "Calling toJson method on object failed."; | 29 return "Calling toJson method on object failed."; |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 first = false; | 817 first = false; |
818 }); | 818 }); |
819 sb.write('}'); | 819 sb.write('}'); |
820 seen.removeLast(); | 820 seen.removeLast(); |
821 return true; | 821 return true; |
822 } else { | 822 } else { |
823 return false; | 823 return false; |
824 } | 824 } |
825 } | 825 } |
826 } | 826 } |
OLD | NEW |