TField OnValidate: Bug or lack of understanding? lazarus / 16-Databases ---------------------------------------------------------------------- kpeters58 · 2014-02-14 04:24 Goal: I want to selectively respond to certain exceptions. To this end, I trap my application's exceptions via a TApplicationProperties.OnException event. To illustrate the issue, assume that I have a TDBEdit hooked up to a float field. All CRUD operations work just fine. Now I want to introduce field validation, so for this field's OnValidation event I have Code: [Select]  if Sender.AsCurrency < 10.0 then     DatabaseError('Value must be 10.0 or bigger');  When run in the debugger, I see the expected EDatabaseError with my message on an attempt to save a value of less than 10.0 - so far, so expected. But after that, a second? exception pops up saying that whatever value I entered is an invalid float, which is a message I do NOT want to show my users. I have tried using a custom exception as well (which I initially see) and which then, too, is followed by a second exception of type EDatabaseError with the same message as stated above - and now I cannot even filter by my custom exception type as the exception being trapped is the 2nd one. Just in case someone is tempted to say: Why don't you validate in OnExitEvents or such - I am well aware of these and do not want to use them. Bug or feature? ---------------------------------------------------------------------- LacaK · 2014-02-15 20:57 Can you reproduce it with simple database application scenario, where are not used DB-aware controls like TDBEdit ? So only any TDataSet with Field with OnValidate event handler and you use: FieldByName('MyField').AsFloat:=1; //here should be raised error in OnValidate ---------------------------------------------------------------------- kpeters58 · 2014-02-16 05:41 Good catch: Works as expected if no DB-aware components are being used. What made you think of your suggestion? ---------------------------------------------------------------------- LacaK · 2014-02-17 06:36 Quote from: kpeters58 on February 16, 2014, 06:41:41 amGood catch: Works as expected if no DB-aware components are being used. What made you think of your suggestion? Only intuition