I have an application which occasionally returns an integer overflow when FormatDateTime
is called. I have no idea what scenario triggers this, although I have found mention of the problem here and here.
My current workaround is to wrap the function and handle the exception:
function FormatDateTimeEx (const FormatString : ANSIString ;
DateTime : TDateTime) : ANSIString ;
begin
try
Result := FormatDateTime (FormatString, DateTime) ;
except
Result := '???' ;
end ;
end ;
which solves the issue of this problem causing the compiled executable to crash, but I would also prefer it if the debugger did not break on the EIntOverflow
exception when I an running the program in the IDE. I don't want to do this by telling the IDE to ignore the EIntOverflow
exception, because then it won't break on other occasions when an untrapped integer overflow occurs (right?).
Is there a programmatic way (compile-time or run-time) of telling the IDE to locally ignore an exception class, for those occasions when an exception can occur, and you already know that and are handling it?
Is there a programmatic way (compile-time or run-time) of telling the IDE to locally ignore an exception class, for those occasions when an exception can occur, and you already know that and are handling it?
Not in code, no. However, it can be done in the debugger using Breakpoints.
Wrap the affected code with two Breakpoints:
function FormatDateTimeEx(const FormatString: AnsiString; DateTime: TDateTime): AnsiString;
begin // <-- breakpoint
try
Result := FormatDateTime (FormatString, DateTime) ;
except
Result := '???';
end;
end; // <-- breakpoint
Go into the Properties of the first Breakpoint and enable the Ignore subsequent exceptions option and disable the Break option.
Go into the Properties of the second Breakpoint and enable the Handle subsequent exceptions option and disable the Break option.