Result<T extends Object, E extends Object>.of constructor
Result<T extends Object, E extends Object>.of (
- T catching()
Call the catching
function and produce a Result
.
If the function throws an error, it will be caught and contained in the
returned result. Otherwise, the result of the function will be contained
as the Ok
value.
Implementation
factory Result.of(T Function() catching) {
try {
return Ok(catching());
} on E catch (e) {
return Err(e);
}
}