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

65 lines
939 B
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()
{
I4 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]);
}
U4 Pmt(I4 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;
Fs->catch_except=TRUE;
}
}
Demo;