#1 2023-03-26 17:50:25

jianwang
Member
Registered: 2023-03-21
Posts: 2

server side crashed when raise exception for interface-based services

below is example code on server side:

Tpublic = class(TInjectableObjectRest, Ipublic)
  public
  procedure ErrorTest(S1,S2:RawUTF8);
end

procedure Tpublic.ErrorTest(S1,S2:RawUTF8);
begin
    //do nothing,just raise a exception
    raise Exception.Create('ErrorTest');
end;

client side code:

procedure TfrmClient.test;
var i:integer;
     FModel: TOrmModel;
     HttpClient: TRestHttpClient;
     publicService: Ipublic;
begin
    FModel := TOrmModel.Create([],'public');
    HttpClient := TRestHttpClient.Create('localhost', '8088', FModel);

   HttpClient.Model.Owner:=HttpClient;
   HttpClient.ServiceDefine([Ipublic], sicShared); 
       if httpClient.Resolve(Ipublic, publicService) then
       begin
          publicService.ErrorTest('d','d');
       end;
end;

when I call test procedure on client side, the server side application crash immediately. is that because I missed something code on server side?

can anyone help me?
thanks  a lot!

Offline

#2 2023-03-26 18:21:58

jianwang
Member
Registered: 2023-03-21
Posts: 2

Re: server side crashed when raise exception for interface-based services

by the way, above problem only accured on lazarus , when the same code compiled by delphi XE, it works fine and the client side could get exception message that sever side raised.

Offline

Board footer

Powered by FluxBB