@@ -13,17 +13,16 @@ T $checkedNew<T>(String className, Map map, T constructor(),
13
13
try {
14
14
return constructor ();
15
15
} on CheckedFromJsonException catch (e) {
16
- if (e._className == null ) {
16
+ if (identical (e.map, map) && e._className == null ) {
17
17
e._className = className;
18
- assert (identical (e.map, map));
19
18
}
20
19
rethrow ;
21
20
} catch (error, stack) {
22
21
String key;
23
22
if (error is ArgumentError ) {
24
23
key = fieldKeyMap[error.name] ?? error.name;
25
24
}
26
- throw new CheckedFromJsonException (error, stack, map, key,
25
+ throw new CheckedFromJsonException ._ (error, stack, map, key,
27
26
className: className);
28
27
}
29
28
}
@@ -38,18 +37,22 @@ T $checkedConvert<T>(Map map, String key, T castFunc(Object value)) {
38
37
} on CheckedFromJsonException {
39
38
rethrow ;
40
39
} catch (error, stack) {
41
- throw new CheckedFromJsonException (error, stack, map, key);
40
+ throw new CheckedFromJsonException ._ (error, stack, map, key);
42
41
}
43
42
}
44
43
45
44
/// Exception thrown if there is a runtime exception in `fromJson`
46
45
/// code generated when `JsonSerializableGenerator.checked` is `true`
47
46
class CheckedFromJsonException implements Exception {
48
47
/// The [Error] or [Exception] that triggered this exception.
48
+ ///
49
+ /// If this instance was created by user code, this field will be `null` .
49
50
final Object innerError;
50
51
51
52
/// The [StackTrace] for the [Error] or [Exception] that triggered this
52
53
/// exception.
54
+ ///
55
+ /// If this instance was created by user code, this field will be `null` .
53
56
final StackTrace innerStack;
54
57
55
58
/// The key from [map] that corresponds to the thrown [innerError] .
@@ -71,7 +74,13 @@ class CheckedFromJsonException implements Exception {
71
74
String _className;
72
75
73
76
/// Creates a new instance of [CheckedFromJsonException] .
74
- CheckedFromJsonException (this .innerError, this .innerStack, this .map, this .key,
77
+ CheckedFromJsonException (this .map, this .key, String className, this .message)
78
+ : _className = className,
79
+ innerError = null ,
80
+ innerStack = null ;
81
+
82
+ CheckedFromJsonException ._(
83
+ this .innerError, this .innerStack, this .map, this .key,
75
84
{String className})
76
85
: _className = className,
77
86
message = _getMessage (innerError);
0 commit comments