PDA

View Full Version : Some problems with exceptions


Adam H.
22-Feb-2009, 11:56 PM
Hi,

I'm having some problems at the moment with one of my applications. I have recently updated from Eurekalog 6.0.14 to 6.0.18 and am not sure if it's related or not.

The problems I have seen are twofold (seperate, but possibly related???):

a) I notice that in some projects if an exception is raised - it is not raised in the IDE debugger, only in the application and b) I also notice that some exceptions within a try/except statement still raise errors within the application (outside of the IDE). (I've had end users report errors that should have been handled by the try/except statement).

I am running Delphi 2007 on a Vista SP1 machine.

Does anyone have any suggestions?

Thanks & Regards

Adam.

Alex
23-Feb-2009, 05:26 PM
Hi.

> I've had end users report errors that should have been handled by the try/except statement

Probably there is an exception inside exept block:

try
InvokeAppocalypse; // <- bad things
except
Cleanup; // <- exception raised here
end;

There can be plenty of other reasons, it is hard to say without seeing some code.

Adam H.
23-Feb-2009, 09:55 PM
Hi Alex,

Thanks for your reply.

Here is the script that I had the problem on:

Main script:
--------------------------------------

try
Table1TurnaroundC.value := timebetween(ticketTWeighIn.value,
TicketTWeighout.value);
finally
end;

--------------------------------------

function timebetween(_now : TDateTime; _Then : TDateTime): String;

Var
secs : integer;
begin
secs := SecondsBetween(_now, _then); // **** Breaks here if integer is too large.

// dosomething else here to return a string value....
--------------------------------------

Cheers

Adam.

Alex
24-Feb-2009, 04:46 AM
Hi, Adam.

I don't see any problems there. The finally block should not catch exeptions - it only reacts to them. So it is not surprising that exception in timebetween will be unhandled in this code block.
Or are you complaining that there can be an exception in SecondsBetween?
Please, tell us more details.

Adam H.
24-Feb-2009, 08:15 PM
I don't see any problems there. The finally block should not catch exeptions - it only reacts to them. So it is not surprising that exception in timebetween will be unhandled in this code block.
Or are you complaining that there can be an exception in SecondsBetween?
Please, tell us more details.

Oh - I think I see what you mean. Instead I should have the code:

try
Table1TurnaroundC.value := timebetween(ticketTWeighIn.value,
TicketTWeighout.value);
except // Replace finally with except here to trap exceptions....
end;

Cheers

Adam.