tryCatch method
Implementation
Future<Validation<T>> tryCatch() =>
then((value) => value).catchError((err) {
if (err is Exception) {
return Invalid<T>([Fail.withException(err)]);
} else if (err is Error) {
return Invalid<T>([Fail.withError(err)]);
}
else if(err is String)
{
return Invalid<T>([Fail.withError(ArgumentError(err))]);
}
return Fail.withError(Error(), message: 'Unknown error').toInvalid<T>();
});