Commit 6b711e3
authored
Improve error messages when typeToCode throws an exception (#1450)
`typeToCode` can throw an expection, which reduces the error message to:
```
UnimplementedError: (InvalidTypeImpl) InvalidType
package:json_serializable/src/utils.dart 221:3 typeToCode
package:json_serializable/src/helper_core.dart 79:46 createInvalidGenerationError
...
```
This change improves the error message to something like this:
```
Could not generate `fromJson` code for `photos` because of type is unimplemented/unsupported/undefined.
package:picthrive_kiosk/ptclient/generated/consolidated_public.swagger.dart:2633:21
╷
2633 │ final List<Items> photos;
│ ^^^^^^
╵
```1 parent 5d5feca commit 6b711e3
3 files changed
Lines changed: 14 additions & 1 deletion
File tree
- json_serializable
- lib/src
- test
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
81 | 86 | | |
82 | 87 | | |
83 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
0 commit comments