Hello Marius,

The following code:

#include <iostream>

int main( void )
{
  try
    {
    try
      {
      throw 999;
      }
    catch ( ... )
      {
      std::cerr << "Rethrowing ellipsis exception!" << std::endl;
      throw;
      }
    }
  catch ( int n )
    {
    std::cerr << "Caught an integer: " << n << std::endl;
    return EXIT_SUCCESS;
    }

  std::cerr << "Failed to catch exception." << std::endl;
  return EXIT_FAILURE;
}


Will catch and rethrow any exception as the same type it catches, so the code 
in ProcessObject should do what you wish.

What are you seeing to indicate that that you don't think that this is working?

Brad





On May 29, 2012, at 8:35 AM, [email protected] wrote:

> Hi all, Gaetan,
>  
> This commit:
>  
> http://itk.org/gitweb?p=ITK.git;a=commitdiff;h=322cb3952a45cbdb4a100a3d308769a6027d4f95
>  
> changed the function ProcessObject::UpdateOutputData. Notably a try-catch was 
> changed from
>  
> try
>       {
>       this->GenerateData();
>       }
>     catch( ProcessAborted & excp )
>       {
>       this->InvokeEvent( AbortEvent() );
>       this->ResetPipeline();
>       this->RestoreInputReleaseDataFlags();
>       throw excp;
>       }
>     catch( ExceptionObject& excp )
>       {
>       this->ResetPipeline();
>      this->RestoreInputReleaseDataFlags();
>       throw excp;
>       }
>  
> to
>  
> try
>     {
>     this->GenerateData();
>     }
>   catch ( ProcessAborted & excp )
>     {
>     this->InvokeEvent( AbortEvent() );
>     this->ResetPipeline();
>     this->RestoreInputReleaseDataFlags();
>     throw excp;
>     }
>   catch (...)
>     {
>     this->ResetPipeline();
>     this->RestoreInputReleaseDataFlags();
>     throw;
>     }
>  
> So itk::ExceptionObject is not explicitely caught anymore.
>  
> In my code I depend on itk::ExceptionObject to be caught and re-thrown. I 
> catch it again higher up, and do something with it (not just stopping the 
> program). With this change the original throw (itkExceptionMacro) ends up in 
> catch(…) and just "throw" is called instead of "throw excp". Is it possible 
> to add an extra catch:
>  
> try
>     {
>     this->GenerateData();
>     }
>   catch ( ProcessAborted & excp )
>     {
>     this->InvokeEvent( AbortEvent() );
>     this->ResetPipeline();
>     this->RestoreInputReleaseDataFlags();
>     throw excp;
>     }
>   catch( ExceptionObject & excp )
>     {
>     this->ResetPipeline();
>     this->RestoreInputReleaseDataFlags();
>     throw excp;
>     }
>   catch (...)
>     {
>     this->ResetPipeline();
>     this->RestoreInputReleaseDataFlags();
>     throw;
>     }
>  
> ?
>  
> which would restore the original working of my code.
>  
> Regards, Marius
>  
> Marius Staring, PhD
> Division of Image Processing (LKEB)
> Department of Radiology
> Leiden University Medical Center
> PO Box 9600, 2300 RC Leiden, The Netherlands
> phone: +31 (0)71 526 2137, fax: +31 (0)71 524 8256
> [email protected]
>  
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.php
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers

========================================================
Bradley Lowekamp  
Medical Science and Computing for
Office of High Performance Computing and Communications
National Library of Medicine 
[email protected]



_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-developers

Reply via email to