parser<T> function
Parser helper that catches model/JSON construction errors and throws a typed ParsingException (which extends your data exceptions).
Implementation
T parser<T>(T Function() build, {required Object? data}) {
try {
return build();
} catch (e, s) {
if (e is BaseException) rethrow;
throw ParsingException(
rawData: data,
targetType: '$T',
cause: e,
stack: s,
);
}
}