[Insight-developers] changes to ProcessObject

M.Staring at lumc.nl M.Staring at lumc.nl
Tue May 29 09:15:18 EDT 2012


Hi Brad,

Ah, it is good to know that the throw without arguments still keeps its type. It's just that I added these lines back and then my program worked again. But the relevant code is a bit scattered around my toolkit, so debugging is a bit complicated. Let me debug somewhat further, maybe it is a combination of factors.

Thanks, Marius

From: Bradley Lowekamp [mailto:blowekamp at mail.nih.gov]
Sent: dinsdag 29 mei 2012 15:02
To: Staring, M. (LKEB)
Cc: insight-developers at itk.org
Subject: Re: [Insight-developers] changes to ProcessObject

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, M.Staring at lumc.nl<mailto:M.Staring at lumc.nl> 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
m.staring at lumc.nl<mailto:m.staring at lumc.nl>

_______________________________________________
Powered by www.kitware.com<http://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

blowekamp at mail.nih.gov<mailto:blowekamp at mail.nih.gov>




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20120529/9d470145/attachment.htm>


More information about the Insight-developers mailing list