Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Exception handling on TClientdataset


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 4 - Last Post: Jul 9, 2014 5:35 AM Last Post By: Andre Coetzer
Andre Coetzer

Posts: 10
Registered: 6/1/08
Exception handling on TClientdataset  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 3, 2014 2:10 AM
I am using a TClientDatset with an XML file to manage my preferences settings. Everything works as planned, but every time I add a new field but don't delete the old XML file I get an error message. While this is not unexpected (and should never really happen once the software reaches a more final version), I do want to catch the error to prevent the program from completely crashing. I have tried the following Try-except loop, but for some reason it doesn't catch the exception. It reaches the first "dmSysDB.cdsPreferences.open;" command, but then breaks with an error and doesn't reach the except command. Is there a way to setup the exception handling so that a "deeper" exception is still handled, or is there another way to help solve this problem?

  if FileExists(dmSysDB.cdsPreferences.FileName) then
  begin
    try
      dmSysDB.cdsPreferences.open;
    except
      SaveDefaultPreferences;  //This line will delete the existing file and create a clean and working version
      dmSysDB.cdsPreferences.open;
    end;
  end


Thanks in advance!
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Exception handling on TClientdataset  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 3, 2014 4:48 AM   in response to: Andre Coetzer in response to: Andre Coetzer
Use
try
 
except else
 
end;


Best regards,
Cristian Peta
Andre Coetzer

Posts: 10
Registered: 6/1/08
Re: Exception handling on TClientdataset  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 3, 2014 5:56 AM   in response to: Cristian Peța in response to: Cristian Peța
Unfortunately that didn't help...

Cristian Peta wrote:
Use
try
 
except else
 
end;
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Exception handling on TClientdataset  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 3, 2014 6:12 AM   in response to: Andre Coetzer in response to: Andre Coetzer
If you are sure you have an exception not handled by try except block you can create a QC. Or if you are not sure you can post an example project in attachments group.
BTW what version of Delphi do you use?

Best regards,
Cristian Peta
Andre Coetzer

Posts: 10
Registered: 6/1/08
Re: Exception handling on TClientdataset  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 9, 2014 5:35 AM   in response to: Cristian Peța in response to: Cristian Peța
Thanks Christian. I will create an example project and post it. I'm using XE5.

Cristian Peta wrote:
If you are sure you have an exception not handled by try except block you can create a QC. Or if you are not sure you can post an example project in attachments group.
BTW what version of Delphi do you use?

Best regards,
Cristian Peta
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02