Trivial Solutions
                    The LoseThos 64-bit PC Operating System
File:/LT/Demo/Exceptions.CPZ
This, and all LoseThos files, are public domain.  Do whatever you like.
God is watching; God is just; God is never out-done in generosity.  He talks!

LoseThos code compiles with the 64-bit LoseThos compiler/assembler I wrote.
Boot the LoseThos CD and you can compile it.  Not in Kansas anymore!

Click here for preliminary compiler information you need.

//WARNING: Don't return out of a catch{}.  This
//might get fixed.

//You can use CatchAll() in a catch statement
//and it will report args.

#define EXCEPT_1        1
#define EXCEPT_2        2
#define EXCEPT_3        3
#define EXCEPT_4        4

U0 Show()
{
  I64 i;
  "Fs->except_argc=%X\n",Fs->except_argc;
  for (i=0;i<Fs->except_argc;i++)
    "Fs->except_argv[%d]=%08X\n",i,Fs->except_argv[i];
}



BoolI64 Pmt(I64 i)
{
  "%d ",i;
  return YorN;
}

U0 D1()
{
  "D1\n";
  if (Pmt(1)) throw(EXCEPT_1);
  if (Pmt(2)) throw(EXCEPT_2,33,55,66);
  if (Pmt(5)) throw;
}

U0 D2()
{
  "D2\n";
  try {
    D1;
    if (Pmt(4)) throw(EXCEPT_4);
  } catch {
    "D2 handler\n";
    Show;
    if (Fs->except_argc>0) {
      if (Fs->except_argv[0]==EXCEPT_1) {
        "Caught in D2\n";
        Fs->catch_except=TRUE;
      }
    }
  }
}

U0 Demo()
{
  try {
    D2;
    if (Pmt(3)) throw;
  } catch {
    "Demo handler\n";
    Show;
    "Ignore Except";
    if (YorN)
      Fs->ignore_except=TRUE;
    else
      Fs->catch_except=TRUE;
  }
}


Demo;
Historical capture: 2012-03-09. Home | Power on LoseThos | Sources and changes