Files
TempleOS-Rijn/LT/Demo/Exceptions.CPZ
T
2018-09-08 21:45:20 +02:00

69 lines
1.0 KiB
Plaintext

//$BK,1$WARNING:$BK,0$ Don't return out of a catch{}. This
//might get fixed.
#define ECP_1 1
#define ECP_2 2
#define ECP_3 3
#define ECP_4 4
void Show()
{
I8 i;
coutln "Fs->except_argc=",Fs->except_argc;
for (i=0;i<Fs->except_argc;i++)
PrintF("Fs->except_argv[%d]=%08X\r\n",i,Fs->except_argv[i]);
}
BoolU8 Pmt(I8 i)
{
cout i;
return YorN;
}
void D1()
{
coutln "D1";
if (Pmt(1)) throw(ECP_1);
if (Pmt(2)) throw(ECP_2,33,55,66);
if (Pmt(5)) throw;
}
void D2()
{
coutln "D2";
try {
D1;
if (Pmt(4)) throw(ECP_4);
} catch {
coutln "D2 handler";
Show;
if (Fs->except_argc>0) {
if (Fs->except_argv[0]==ECP_1) {
coutln "Caught in D2";
Fs->catch_except=TRUE;
}
}
}
}
void Demo()
{
try {
D2;
if (Pmt(3)) throw;
} catch {
coutln "Demo handler";
Show;
cout "Ignore Except";
if (YorN)
Fs->ignore_except=TRUE;
else
Fs->catch_except=TRUE;
}
}
Demo;