inspectErr abstract method
Calls the provided closure with the contained error (if Err
).
Examples
Result<int, String> parseToInt(String value) {
try {
return Ok(int.parse(value));
} catch (_) {
return Err(value);
}
}
Result<int, String> x = parseToInt('four')
.inspectErr((val) => print("'$val' could not be parsed into an integer")) // prints "'$four' could not be parsed into an integer"
Implementation
Result<T, E> inspectErr(void Function(E error) f);