Abort in a before post

Hi,

I would like to do validations in a BeforePost event of a Dataset.
If a validation fails I do an abort.

However: the abort seems not to be a silent exception in Web Core as it triggers a clear exception in the application (red bar at the bottom).

I then tried to catch the EAbort exception by following code, it seems the code in AppError is executed but though Handled := true I still the red error box at the bottom of the screen.

How to cancel in a BeforePost ?

procedure TfrmMain.WebFormCreate(Sender: TObject);
begin
    Application.OnError := AppError;
end;

procedure TfrmMain.AppError(Sender: TObject; AError: TApplicationError; var Handled:Boolean);
begin
  Handled:=True;
  console.log('From Application.OnError: '+AError.AMessage);
  console.log('Object from Application.OnError');
  console.log(AError);
end;
1 Like

We'll bring this up with the pas2js team.
You can avoid the red box though by setting
Application.ErrorType = aeSilent