From: pavenis AT lanet DOT lv To: "Johnson, Nate" , djgpp AT delorie DOT com Date: Wed, 19 Jul 2000 18:50:51 +0200 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: RE: Exception Handling Message-ID: <3975F88B.1436.1481E1B@localhost> In-reply-to: <2F5D18165CB1D2119E0D00805F65BBC80496D3B1@newhampshire.exchange.indiana.edu> X-mailer: Pegasus Mail for Win32 (v3.12c) Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 19 Jul 2000, at 7:51, Johnson, Nate wrote: > i havent used djgpp in awhile, but when i used "user defined" exceptions in > msvc i always use the new operator when using exceptions, like this... > > throw new exception("Error message here"); > There is no need for this. throw exception("Error message here"); should work Ok. Some notes: I recommend not naming class as simply exception to avoid confusion with class which already already exists (see #include ) Don't use -fomit-frame-pointer. It dosn't live nicely together with throwing exceptions. It may work, but it may also crash. Andris > > -----Original Message----- > From: Dogansmoobs [mailto:dogansmoobsNOdoSPAM AT hotmail DOT com DOT invalid] > Sent: Tuesday, July 18, 2000 3:37 PM > To: djgpp AT delorie DOT com > Subject: Exception Handling > > > I am having a problem with exception handling. Whenever I try > to cathch and exception, instead of running what's in the catch > block, it exits the program and displays Abort!!. Is there > something I'm missing, or doing wrong?? Here's what I'm doing: > > #include > > class exception > { > public: > exception(char *message) > { > strcpy(errorMessage, message); > } > > void display() > { > cout << errorMessage; > } > > private: > char *errorMessage; > }; > > Then whin I want to throw an exception, I say: > throw exception("Error message here"); > > and then catch it using: > catch (exception &e) > > but it never does this, it just aborts. And yes, the code that > produces the exception is in a try block. > > - Dogansmoobs > http://wookie.freehosting.net/ > I would call myself Duncan Blownuts, but people might think I'm > insane. > > > ----------------------------------------------------------- > > Got questions? Get answers over the phone at Keen.com. > Up to 100 minutes free! > http://www.keen.com