catch coroutine error in example
parent
b0e8b3fbd0
commit
8686962cbc
|
@ -42,7 +42,13 @@ int main() {
|
||||||
int val = 5;
|
int val = 5;
|
||||||
for (int i: range(steps)) {
|
for (int i: range(steps)) {
|
||||||
writeln(" calling into coroutine...");
|
writeln(" calling into coroutine...");
|
||||||
auto v = f(val);
|
int v;
|
||||||
|
try {
|
||||||
|
v = f(val);
|
||||||
|
} catch (coroutine_error const &e) {
|
||||||
|
writefln(" coroutine failed: %s", e.what());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
writefln(" called into coroutine which yielded: %s", v);
|
writefln(" called into coroutine which yielded: %s", v);
|
||||||
writefln(" call loop iteration %s done", i + 1);
|
writefln(" call loop iteration %s done", i + 1);
|
||||||
writefln(" coroutine dead: %s", !f);
|
writefln(" coroutine dead: %s", !f);
|
||||||
|
@ -290,6 +296,5 @@ starting main...
|
||||||
call loop iteration 6 done
|
call loop iteration 6 done
|
||||||
coroutine dead: true
|
coroutine dead: true
|
||||||
calling into coroutine...
|
calling into coroutine...
|
||||||
terminating with uncaught exception of type ostd::coroutine_error: dead coroutine
|
coroutine failed: dead coroutine
|
||||||
zsh: abort ./coro
|
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue