func_type_result 0.0.1 copy "func_type_result: ^0.0.1" to clipboard
func_type_result: ^0.0.1 copied to clipboard

Simple functional result-type for alternative exception-handling.

Features #

Simple functional result-type for alternative exception-handling.

Example #

final rand = Random();

T mightFail<T>(T value) {
  if (rand.nextBool()) {
    return value;
  } else {
    throw Exception("Woopsi!");
  }
}

main() {
  result(() => mightFail("Some value"))
      .map((value) => value + "success")
      .flatMap((value) => result(() => value.toInt()))
      .whenErr((ex) => println(ex));
}
1
likes
150
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

Simple functional result-type for alternative exception-handling.

Repository (GitLab)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on func_type_result