I am trying to clean up a lot of my code messes. I am trying to implement error handling where possible and this is my first go at use try...except... statements. I have used them, typically what I copied from examples on the net. I really need my procedure to exit or abort if an exception happens. Simply calling exit; after the On E: EInOutError do gives me a compile error. Expects end;
This is a sample of my attempt, can I only have one statement for the on E: do ... statement?
if dlgFMsaveTarget.Execute then
begin
// create target file
try
AssignFile(TargetFileOD, dlgFMsaveTarget.FileName);
Rewrite(TargetFileOD);
CloseFile(TargetFileOD);
except
on E: EInOutError do
ShowMessage('File handling error occurred. Details: ' +
E.ClassName + '/' + E.Message);
//exit; // there was an error... need to get out of entire procedure
end;
end else exit; //user pressed cancel in dialog - get out of here
startProcessing;