Excp.h

Classes

ExcpError -- Base class for exception error classes (full description)

class ExcpError

Interface

Public Members
Int thrownLine() const
const Char *thrownFile() const
ExcpError(const Int excp_num)
ExcpError()
ExcpError(ExcpError *excp)
virtual ~ExcpError()
rtti_dcl_mbrf(ExcpError)

Description

Synopsis

This is the base class for all exceptions. It contains all of the hooks to allow the try, throw, catch, and rethrow macros to work.

Warning Classes which derive from this base class need to define a constructor which takes an ExcpError* as its only parameter. This constructor should set the _equal variable to True if the the ExcpError pointed to by the parameter is of the type of the object being constructed. This is not pretty, but it is the only way for the catch clauses to work. Also, don't forget to copy any other members if the types match.

Example

In the header file (.h):
    rtti_dcl_init(DummyError);
    class DummyError : public ExcpError {
      public:
        DummyError() {}
        DummyError(ExcpError *excp);
        ~AipsError() {}
        rtti_dcl_mbrf_p1(DummyError,ExcpError);
    };
In the source file (.cc):
     rtti_imp_init(DummyError);
     rtti_imp_mbrf(DummyError);
     DummyError::DummyError(ExcpError *excp) : ExcpError(excp)
     {
         DummyError *tmp;
         PCAST(tmp,DummyError,excp);
         if (tmp) {
             _equal = True;
             //!!! COPY MEMBERS HERE !!!
         } else {
            _equal = False;
         }
     }

Motivation

Needed for the exception mechanism.

To Do

Member Description

Int thrownLine() const

const Char *thrownFile() const

ExcpError(const Int excp_num)

This constructor can be used to store a exception number for the current exception. However this is being taken out.

ExcpError()

Construct an ExcpError.

ExcpError(ExcpError *excp)

virtual ~ExcpError()

Does nothing

rtti_dcl_mbrf(ExcpError)