Welcome, Guest. Please login or register.

Author Topic: Exception troubles!  (Read 26859 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Exception troubles!
« on: December 12, 2002, 10:45:11 AM »
Hi all,
   I've been writing some system classes in StormC/C++ v3. I have written a threadable class (similar to Thread in java) that encapsulates a dos Process. Everything is fine apart from exception handling. Whenever any given thread method throws an exception, it seems that the actual task that threw it isn't always the one to catch it.
  For example, the protected GoIdle() method only ever throws an IllegalAccess if not called by the internal task. Other methods eg Wake() thow exceptions if they are called by the internal task.
  So imagine our thread is sleeping via GoIdle(). The only exception it is expecting is IlegalAccess, which shouldn't happen anyway because it has been called by the internal task. Everything is fine so far. Now imagine the parent task calls some method such as Start() that will throw AlreadyRunning. The internal thread ends up catching this!!
  Have actually managed to prove this by catching AlreadyRunning from the following fragment

  /* this code executed by internal task */
  try {
    GoIdle();
  }
  catch (AlreadyRunnging) {
  // not even thrown by GoIdle()!!
  cerr << "Bloody Hell!\n";
  }
  catch (IllegalAccess) { /* Nowt to do */  }
 
  Basically the whole thing then crashes as the wrong stack is unwound!
   I'm aiming for portability and really want to use execptions for error handling rather than having to use return values etc. Any help welcome!!!
int p; // A
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Exception troubles!
« Reply #1 on: January 22, 2003, 09:30:47 AM »
Thanks!

Can't hang about today, so I'll probably be offline when you read this...

I also think that the problem lies in StormC implementation. I have catalogued some serious problems with StormC v3 over the time I have been using it. For example, my major gripes are

1. Broken function template instansation, eg