Application.OnException := BSException;//Exception catch
procedure TfmClient.BSException(Sender: TObject; E: Exception);
begin
// EOSError System Error. Code: 5. Access is denied.
.if Pos('System Error.Code: 5.',e.Message) > 0 then abort
;
//Since the form is closed when the data is not fetched, the address of the module will be wrong.
if Pos('dsnap70.bpl',e.Message) > 0 then
abort;
if Pos('Cannot create form. No MDI forms are currently active',e.Message) > 0 then
halt;
ShowMessage(e.Message); //Pop up exception message
end;