Reputation: 26660
DateUtils.TryISO8601ToDate('8', Result)
generates an exception. But it is Try !!! It's task is to try without throwing any exceptions.
The problem is not that Delphi IDE reacts on this exception. The problem is that the "Try" function produces such an exception instead of returning true/false.
Upvotes: 0
Views: 330
Reputation: 30735
I think you may need to adjust your IDE debugger options.
In the IDE go to Tools | Options and on the Language Exceptions tab below Debugger Options | Embarcadero Debuggers, uncheck the Notify on Language Exceptions
box.
With that box checked, the debugger will stop execution in the IDE before your (or the RTL's) exception-handling executes. It pops up a dialof asking whether you want to break execution or continue. If you choose the latter, the exception handler in the code will then execute.
Update Tbh, with the updates to your q, I'm not at all clear what you are saying is the problem. Which part of the following code does not behave as you expect/wish and how?
procedure TForm1.TestISODates;
var
S : String;
DT : TDateTime;
begin
DT := Now;
S := DateToISO8601(DT, False);
Caption := S;
if TryISO8601ToDate(S, DT, False) then
Caption := 'OK';
S := 'banana';
if TryISO8601ToDate(S, DT, False) then
Caption := 'OK'
else
Caption := S + ' not ok';
end;
Upvotes: 3