[Insight-users] itkExceptionMacro not working in my ia64 buil d

Miller, James V (Research) millerjv at crd.ge.com
Tue Jun 29 16:05:54 EDT 2004


Rocky, 

This is how C++ exceptions work. If there is no one around to catch the
exception, the program ends up unwinding the complete call stack. So 
you end up with a core dump. We try to limit exceptions to truly
"exceptional"
circumstances, out of memory, unknown file, etc.

You have to explictly catch an exception if you want your program
to handle it.  There can be several catch clauses stacked together to 
catch different types of exceptions (in case you can handle them
differently)

  try 
    {
    writer->Update();
    }
  catch( itk::ExceptionObject & excep )
    {
    std::cerr << "Exception catched !" << std::endl;
    std::cerr << excep << std::endl;
    }
  catch (...)
    {
    std::cerr << "Unknown exception" << std::endl;
    }

You might for instance, catch the exception of the writer and tell user
"Hey, I need a valid filename!" and then prompt for input and try again.





-----Original Message-----
From: Rocky Rhodes [mailto:rhodes at sgi.com]
Sent: Tuesday, June 29, 2004 3:03 PM
To: 'Miller, James V (Research)'; 'insight-users at itk.org'
Subject: RE: [Insight-users] itkExceptionMacro not working in my ia64
buil d


That did successfully catch and print out the exception.  Is this expected
behavior for an uncaught exception in C++, i.e. core dump without printing
any info about the exception?

Sorry for the naivete.  I'm an old C programmer with some Java background
trying to figure out C++.

	Rocky

> -----Original Message-----
> From: Miller, James V (Research) [mailto:millerjv at crd.ge.com]
> Sent: Tuesday, June 29, 2004 11:45 AM
> To: 'Rocky Rhodes'; 'insight-users at itk.org'
> Subject: RE: [Insight-users] itkExceptionMacro not working in my ia64
> buil d
> 
> 
> Rocky, 
> 
> Have you tried putting the call to Write() in a try/catch block?
> 
>   try 
>     {
>     writer->Update();
>     }
>   catch( itk::ExceptionObject & excep )
>     {
>     std::cerr << "Exception catched !" << std::endl;
>     std::cerr << excep << std::endl;
>     }
> 
> 
> -----Original Message-----
> From: Rocky Rhodes [mailto:rhodes at sgi.com]
> Sent: Tuesday, June 29, 2004 2:09 PM
> To: 'insight-users at itk.org'
> Subject: [Insight-users] itkExceptionMacro not working in my 
> ia64 build
> 
> 
> I spent a bit of time trying to debug the 
> GaussianBlurImageFunction example
> before figuring out that the code was calling 
> itkExceptionMacro trying to
> tell me that the type of PNG file I was trying to write 
> wasn't supported.
> When I run the program I see "Abort (core dumped)" on my 
> shell window and
> the core file is no help unwinding the call stack past a call to
> __cxa_call_unexpected.  The string passed to 
> itkExceptionMacro in the source
> code is nowhere to be seen.
> 
> Has this been a problem on any other platforms?
> 
> 	Rocky
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 


More information about the Insight-users mailing list