How do we define C++ exceptions?

Asked by Rick Stovall

Basically, we have two easy options for defining exceptions in C++ classes and programs: We can use the POCO::Exception class or the older and less capable NTRB::base_exception.

Setup for either is pretty simple, but the Poco::Exception class has the advantage of being able to carry significant additional information about the exception with very little extra effort. Both of the following examples would occur in the public section of the transceiver class header...

The old style exception is declared like this:

    // parent of all transceiver exceptions.
    class general_exception:: public ntrb::base_exception {}

The Poco::Exception version is like this:

          // parent of all transceiver exceptions
   POCO_DECLARE_EXCEPTION(transceiver, general_exception, Poco::Exception)

I don't see either as very complex or hard to use, but knowing the limitations of the older NRTB::base_exception (a rebranded ricklib::base_exception of which I'm the original author), I'd prefer to use the Poco::Exception class.

Whichever way we go, I'd like for us to be consistent within NRTB and I'd like us to settle this soon so that we don't have to go back and re-engineer a lot of stuff to get it all in line later. Therefore, I'm gonna hold this question open until Friday, March 11th, 2011, at which time a final decision will be published.

Question information

Language:
English Edit question
Status:
Solved
For:
New Real Time Battle Edit question
Assignee:
No assignee Edit question
Solved by:
Rick Stovall
Solved:
Last query:
Last reply:
Revision history for this message
George Jordan (gsjordanc) said :
#1

I personally don't mind either one, but agree that we need to decide on one style or the other.

Therefore, I'll throw my preference toward the poco exception library for the reason of increased functionality.

Revision history for this message
Rick Stovall (fpstovall) said :
#2

Rick Stovall suggests this article as an answer to your question:
FAQ #1072: “Alpha Development FAQ”.

Revision history for this message
Rick Stovall (fpstovall) said :
#3

I'm not using any POCO exceptions at the moment, instead favoring my old nrtb::base_exception class for the alpha phase. We can revisit this question later as we prep for beta.