Skip to content

Commit f3be8df

Browse files
committed
Avoid null values for CheckedFromJsonException.message
...by using `toString()` with unrecognized error types. Fixes #745
1 parent 7f1eb7d commit f3be8df

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

_test_yaml/test/yaml_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ builders:
6868
- a
6969
- b
7070
''': r'''
71-
line 2, column 1 of file.yaml: Unsupported value for "builders".
71+
line 2, column 1 of file.yaml: Unsupported value for "builders". type 'YamlList' is not a subtype of type 'Map<dynamic, dynamic>' in type cast
7272
7373
2 │ ┌ - a
7474
3 │ └ - b
@@ -88,7 +88,7 @@ builders:
8888
a:
8989
target: 42
9090
''': r'''
91-
line 3, column 13 of file.yaml: Unsupported value for "target".
91+
line 3, column 13 of file.yaml: Unsupported value for "target". type 'int' is not a subtype of type 'String' in type cast
9292
9393
3 │ target: 42
9494
│ ^^

json_annotation/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## 3.1.1-dev
22

3+
- Avoid `null` values for `CheckedFromJsonException.message` by using
4+
`toString()` with unrecognized error types.
35
- Added a helpful `UnrecognizedKeysException.toString()`.
46
- Fixed doc comments for `JsonSerializable.genericArgumentFactories`.
57

json_annotation/lib/src/checked_helpers.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class CheckedFromJsonException implements Exception {
117117
}
118118
return message;
119119
}
120-
return null;
120+
return error.toString();
121121
}
122122

123123
@override

0 commit comments

Comments
 (0)