Exceptions/Catch an exception thrown in a nested call: Difference between revisions

Content added Content deleted
(→‎{{header|C}}: Us of U1 & U2 aids comparison)
Line 314: Line 314:
In conclusion, try/throw/catch keywords are not available in C, nor is
In conclusion, try/throw/catch keywords are not available in C, nor is
their functionality, so while the following code tries to fulfill the task's
their functionality, so while the following code tries to fulfill the task's
requirements, no attempt is made to minic them. The goal has been to provide
requirements, no attempt is made to mimic them. The goal has been to provide
some modicum level of usefulness for someone actually looking at this for
some modicum level of usefulness for someone actually looking at this for
ideas for their own code.
ideas for their own code.
{{incomplete|C|Missing use of U1 & U2}}
U0 and U1 are boring for debugging purposes. Added something to help with that.
U0 and U1 are boring for debugging purposes. Added something to help with that.


Line 384: Line 383:
void baz(int n) {
void baz(int n) {
if (! n) {
if (! n) {
Push_Ex(GLOBALEX, U0_DRINK_ERROR , "Drink Error. Insufficient drinks in bar Baz.");
Push_Ex(GLOBALEX, U0_DRINK_ERROR , "U0 Drink Error. Insufficient drinks in bar Baz.");
return;
return;
}
}
else {
else {
Push_Ex(GLOBALEX, U1_ANGRYBARTENDER_ERROR , "Bartender Error. Bartender kicked customer out of bar Baz.");
Push_Ex(GLOBALEX, U1_ANGRYBARTENDER_ERROR , "U1 Bartender Error. Bartender kicked customer out of bar Baz.");
return;
return;
}
}
Line 446: Line 445:
Bar door is open.
Bar door is open.
Bar door is closed.
Bar door is closed.
I am foo() and I deaall wrth U0 DriNk Errors with my own bottle... GOT oNE! [Drink Error. Insufficient drinks in bar Baz.]
I am foo() and I deaall wrth U0 DriNk Errors with my own bottle... GOT oNE! [U0 Drink Error. Insufficient drinks in bar Baz.]
Foo left the bar.
Foo left the bar.
Foo entering bar again.
Foo entering bar again.
Bar door is open.
Bar door is open.
Bar door is closed.
Bar door is closed.
*** Error: Bartender Error. Bartender kicked customer out of bar Baz.
*** Error: U1 Bartender Error. Bartender kicked customer out of bar Baz.
</lang>
</lang>