mapCatching<R> method
Maps the result with the given transform
If the transform
throws an Exception, it is wrapped in a failure with Resource.Exception.Other.
Implementation
ResourceTry<R> mapCatching<R>(R Function(SuccessT value) transform) {
try {
return ResourceTry.success((transform(getOrThrow())));
} on Exception catch (e) {
return ResourceTry.failure(ResourceException.wrap(e));
} on OutOfMemoryError catch (e) {
// We don't want to catch any Error, only OOM.
return ResourceTry.failure(ResourceException.wrap(e));
}
}