core/guard library

Functions

guard<T>(Future<T> action(), {String? source, FutureOr<void> onSuccess(T value)?, FutureOr<void> onError(BaseException e)?, bool manual = false, Map<String, dynamic> additionalContext = const {}}) Future<Result<T, BaseException>>
Guards an async action:
guardSync<T>(T compute(), {String? source, void onSuccess(T value)?, void onError(BaseException e)?, bool manual = false, Map<String, dynamic> additionalContext = const {}}) Result<T, BaseException>
Guards a synchronous computation with the same semantics as guard.
normalizeError(Object error, StackTrace stack, {String? source, Severity defaultSeverity = Severity.error}) BaseException
Normalizes arbitrary errors into your BaseException hierarchy.
parser<T>(T build(), {required Object? data}) → T
Parser helper that catches model/JSON construction errors and throws a typed ParsingException (which extends your data exceptions).