@@ -23,7 +23,7 @@ T $checkedNew<T>(String className, Map map, T constructor(),
23
23
if (error is ArgumentError ) {
24
24
key = fieldKeyMap[error.name] ?? error.name;
25
25
}
26
- throw new CheckedFromJsonException ._ (error, stack, map, key,
26
+ throw new CheckedFromJsonException (error, stack, map, key,
27
27
className: className);
28
28
}
29
29
}
@@ -38,28 +38,44 @@ T $checkedConvert<T>(Map map, String key, T castFunc(Object value)) {
38
38
} on CheckedFromJsonException {
39
39
rethrow ;
40
40
} catch (error, stack) {
41
- throw new CheckedFromJsonException ._ (error, stack, map, key);
41
+ throw new CheckedFromJsonException (error, stack, map, key);
42
42
}
43
43
}
44
44
45
45
/// Exception thrown if there is a runtime exception in `fromJson`
46
46
/// code generated when `JsonSerializableGenerator.checked` is `true`
47
47
class CheckedFromJsonException implements Exception {
48
+ /// The [Error] or [Exception] that triggered this exception.
48
49
final Object innerError;
50
+
51
+ /// The [StackTrace] for the [Error] or [Exception] that triggered this
52
+ /// exception.
49
53
final StackTrace innerStack;
54
+
55
+ /// The key from [map] that corresponds to the thrown [innerError] .
56
+ ///
57
+ /// May be `null` .
50
58
final String key;
59
+
60
+ /// The source [Map] that was used for decoding when the [innerError] was
61
+ /// thrown.
51
62
final Map map;
52
- final Object message;
53
63
54
- String _className;
64
+ /// A human-readable message corresponding to [innerError] .
65
+ ///
66
+ /// May be `null` .
67
+ final String message;
68
+
69
+ /// The name of the class being created when [innerError] was thrown.
55
70
String get className => _className;
71
+ String _className;
56
72
57
- CheckedFromJsonException ._(
58
- this .innerError, this .innerStack, this .map, this .key,
73
+ /// Creates a new instance of [ CheckedFromJsonException] .
74
+ CheckedFromJsonException ( this .innerError, this .innerStack, this .map, this .key,
59
75
{String className})
60
76
: _className = className,
61
77
message = _getMessage (innerError);
62
78
63
- static Object _getMessage (Object error) =>
64
- (error is ArgumentError ) ? error.message : null ;
79
+ static String _getMessage (Object error) =>
80
+ (error is ArgumentError ) ? error.message? . toString () : null ;
65
81
}
0 commit comments