Custom exceptions globally

Hi,

We have both dataabstract and remote services inside one project and we want to intercept all error messages on one place and raise our custom implementation of exception class. Is that possible for both sdks on single place and how we can achieve that?

What we tray to do is to intercept error messages inside OnWriteException event but without succes as this event is called later in hierarchy. Here is examle:

procedure TServerDataModule.MessageWriteException(Sender: TROMessage; aStream: TStream; E: Exception);
begin
e:=getRaiseErrorMessage(e.Message);
end;

Server is running on Delphi (9.x)

you can create descendant from std invoker and override CustomHandleMessage method like

type
  TMyDataService_Invoker = class(TDataService_Invoker)
  protected
    function CustomHandleMessage(const aFactory: IROClassFactory;
      const aMessage: IROMessage;
      const aTransport: IROTransport;
      out oResponseOptions: TROResponseOptions): boolean;  override;
  end;

function TMyDataService_Invoker.CustomHandleMessage(
  const aFactory: IROClassFactory; const aMessage: IROMessage;
  const aTransport: IROTransport;
  out oResponseOptions: TROResponseOptions): boolean;
begin
  try
    result := inherited CustomHandleMessage(aFactory, aMessage, 
                                            aTransport, oResponseOptions);
  except
    on E: Exception do
      raise MyException.Create(getRaiseErrorMessage(e.Message));
   end;
end;

var
  fClassFactory: IROClassFactory;
initialization
  fClassFactory := TROClassFactory.Create('DataService', Create_DataService, 
              TMyDataService_Invoker);
  // RegisterForZeroConf(fClassFactory,'_DataService_rosdk._tcp.');
finalization
  UnRegisterClassFactory(fClassFactory);
  fClassFactory := nil;
end.

Nice.
Thanx

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

Can I get session in CustomHandleMessages.
I need some session variable

you have aMessage.ClientID in CustomHandleMessage so you can get TROSession from SessionManager for this ClientID.