Mail Archives: djgpp/2000/07/19/12:53:26
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 <exception>)
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 <iosteam>
>
> 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
- Raw text -