google / google/built_value.dart

Create a hook for intercepting serialisiation errors

Open
#1,333 1 comment 0 reactions 1 assignee Claimed by @davidmorgan View on GitHub
question
Dominant language
Dart
Stars
886
Forks
195
Avg merge
1d 11h
Merged PRs (30d)
4

Description

### Use-Case
We don't just want to provide a default value in case certain fields can't be parsed or are not present in the JSON. But also intercept these issues so we can log & monitor it, when it happens.

### Example DSLs

#### 1)
```
abstract class MyValue {
@BuiltValueHook(: true)
static void _logError(MyValueBuilder b, Exception e, String key) => logger.logError(ParsingError(e, key))
```

or maybe even better would be to do the same globally

#### 2) A global plugin that logs all deserialization exceptions 🤔
This is assuming if `@nullable` is used and if that field can't be parsed, the value will be null and now exceptions will be thrown

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.