cace 0.0.2 copy "cace: ^0.0.2" to clipboard
cace: ^0.0.2 copied to clipboard

Comprehensive asynchronous contexts for errors. Separate the handling of errors from attaching contexts to them.

example/example.dart

import 'package:cace/cace.dart';

Future<int> square(int x) async {
  await Future.value(); // Some async operation going on
  if (x == 3) {
    throw FormatException();
  }
  return x * x;
}

Future<List<int>> squareAll(List<int> l) {
  final x = Future.wait(l.map((x) => withContext(x, () => square(x))));
  return x;
}

void main() async {
  try {
    final res = await squareAll([0, 1, 3]);
    print(res);
  } catch (e) {
    print('Caught exception with context ${getContextFor(e)}');
  }
}
1
likes
160
points
17
downloads

Publisher

unverified uploader

Weekly Downloads

Comprehensive asynchronous contexts for errors. Separate the handling of errors from attaching contexts to them.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on cace