Reputation: 1554
I have a mainloop within my C++ program. I also have a function for exception handling.
It's syntax looks like this:
void handleEx(int errorCode)
After calling this function I always use continue;
to restart my loop, so it looks like this:
if(/*exception occured*/)
{
handleEx(5);
continue;
}
Is it possible to put the continue;
inside the function so I wouldn't have to rewrite that command and the {}
?
Upvotes: 2
Views: 2959
Reputation: 15446
You should have the function return a bool
so your function header will look like bool handleEx(int errorCode);
and then within the while loop you can do:
while(something) {
//...
if(handleEx(myError)) continue;
//...
}
Upvotes: 2