Result<V extends Object, E extends Exception>.wrapException constructor

Result<V extends Object, E extends Exception>.wrapException(
  1. E wrapExceptionFactory(
    1. Exception exception
    ),
  2. Result<V, Exception> result,
  3. Type? classLocation,
  4. String? functionLocation,
  5. Map<String, dynamic> monitor,
  6. Map<String, dynamic> debug,
  7. Iterable<Log> histories,
)

syntax sugar.

Implementation

factory Result.wrapException(
    E Function(Exception exception) wrapExceptionFactory,
    Result<V,Exception> result,
    Type? classLocation,
    String? functionLocation,
    Map<String, dynamic> monitor,
    Map<String, dynamic> debug,
    Iterable<Log> histories,
) {
    switch (result) {
        case Success(asValue: final value):
            return Success(value, classLocation, functionLocation, monitor, debug, histories);
        case Failure(asError: final error):
            final exception = wrapExceptionFactory(error);
            return Failure(exception, classLocation, functionLocation, monitor, debug, histories);
    }
}