Subject: ErrThrow and constructors
From: Laurens <[EMAIL PROTECTED]>
Date: Tue, 22 Feb 2005 12:46:08 +0100
X-Message-Number: 6

Hi,


Are there any caveats to using ErrThrow in constructors?

I'm using PRC-Tools and want to have some structured error handling in
my code. For instance, I'm allocating memory in the constructor and want
to bail out as soon as possible in case this fails.

XMLReader::XMLReader (UInt16 bufferSize)
{
     m_buffer = MemPtrNew(bufferSize);
     if (!m_buffer) {
         ErrThrow(errNoMemory);
     }
}

Standard C++ exceptions apparently do not work with PRC Tools; the
documentation states that "actually throwing an exception is probably
currently broken anyway". I have to resort to the ErrTry, ErrThrow and
ErrCatch macros.

Why not just check for (m_buffer == NULL) after and external to the constructor then take error action.



Roger Stringer Marietta Systems, Inc. (www.rf-tp.com)


-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to