Right now if a fiber fails, we can only handle errors at the fiber creation site.
Allow to handle error on any resume or resolve:
fun count(num n) > str > num? {
for (num i = 0; i < n; i = i + 1) {
if (i == 2) {
throw "an error occured";
}
yield i;
}
return "Counting is done!";
}
fun main() > void {
fib<str, num?> counter = &count(10);
num sum = 0;
while (!counter.over()) {
sum = sum + (resume counter catch 0) ?? 0;
}
print(resolve counter catch "Ooops);
}
A fiber that failed on a resume is over. A subsequent resume or resolve should raise an error.
Right now if a fiber fails, we can only handle errors at the fiber creation site. Allow to handle error on any
resume
orresolve
:A fiber that failed on a
resume
is over. A subsequentresume
orresolve
should raise an error.