google / google/built_value.dart
BuiltJsonSerializers throws an Error on deserialization exception but it should?
- Dominant language
- Dart
- Stars
- 886
- Forks
- 195
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 4
Description
My current use case is that I'm using [chopper](https://github.com/lejard-h/chopper) to send HTTP requests and made it to use serialization with built_value, so all requests are serialized/deserialized with this.
On Every HTTP request, I catch errors to avoid unhandled cases. I found out that there may be cases where I defined a backend response in a way but for some reason it started sending another json or missed some params.
I want to monitor these cases and for that, I need to handle this case in my app.
# Current
In the current implementation of the json serializers, it throws a `DeserializationError` and if you catch that in your code there's a linter that rise:
- Lint: https://dart-lang.github.io/linter/lints/avoid_catching_errors.html
The error is thrown here:
- https://github.com/google/built_value.dart/blob/8b3dd1b4958384ac6183d7a4d08cad42cad1baae/built_value/lib/src/built_json_serializers.dart#L180
# Proposal
Return an `Exception` instead of an Error because this is something that you as a developer must handle, right? In your workflow, this kind of error may occur and having an error
Contributor guide
Assessment
This issue has not been assessed yet.