[Dcmlib] gdcm exception during new gdcm::File()

Benoit Regrain benoit.regrain at creatis.insa-lyon.fr
Mon May 16 15:21:18 CEST 2005


Hi,

I will let others answer concerning the use of exceptions.
But on this point, I think it's some tests or examples (but it's to
verify).

Concerning the creation of your gdcm::File :
 - If the file doesn't exist (like I have understand in your mail), 
   it's identic to create an empty gdcm::File by
         dcfile = new gdcm::File();
 - If your file exists, there's anormal that it's now not readable and
   generate an exception. In this case, please send the image to
   JPR (our guru of Dicom files) at : jean-pierre.roux at creatis.insa-lyon.fr

Cheers
Benoit Regrain


----- Original Message ----- 
From: "gbook" <gbook at gbook.org>
To: <dcmlib at creatis.insa-lyon.fr>
Sent: Monday, May 16, 2005 2:04 PM
Subject: [Dcmlib] gdcm exception during new gdcm::File()


> I'm having some trouble creating a new gdcm::File(filename) object with 
> gdcm 1.0. I didn't have this problem with 0.6 though. I try to create a 
> File object like this: (filepath = "C:\gdcmData\00191113.dcm")
> 
>       dcfile = new gdcm::File(filepath.c_str());
> 
> It fails with an unhandled exception error. When I place it inside a 
> try/catch statement, it fails gracefully without raising an exception.
> 
>   try { dcfile = new gdcm::File(filepath.c_str()); }
>   catch (...) {
>       logWnd->AppendText(msg.Format("Creating a new gdcm file 
> failed...\n"));
>       return 0;
>   }
> 
> But... when I try to catch the error in an exception object, it fails 
> with an unhandled exception error:
> 
>   try {
>       dcfile = new gdcm::File(filepath.c_str());
>   }
>   catch (gdcm::FileError e) {
> //        logWnd->AppendText(msg.Format("Creating a new gdcm file 
> failed...(%s)\n", theError.c_str()));
>       logWnd->AppendText(msg.Format("Creating a new gdcm file 
> failed...\n"));
>       return 0;       
>   }
> 
> 
> So, I have two questions: 1) what is the proper way to catch exceptions 
> originating from gdcm function calls. 2) The files I'm using work fine 
> with gdcm 0.6, but not with 1.0. Is there a change in the way it reads 
> files in 1.0?
> I'm using MS Visual C++ on Windows 2000. I'm also using wxWidgets.
> 
> Thanks
> -Greg Book
> 
> _______________________________________________
> Dcmlib mailing list
> Dcmlib at creatis.insa-lyon.fr
> http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib



More information about the Dcmlib mailing list