You've already forked lazarus-ccr
Better transport error reporting : ETransportExecption.ExtendedErrorInfo (Thanks to Michael Van Canneyt)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3023 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -65,7 +65,14 @@ type
|
|||||||
|
|
||||||
EServiceException = class(Exception) end;
|
EServiceException = class(Exception) end;
|
||||||
EServiceExtensionException = class(Exception) end;
|
EServiceExtensionException = class(Exception) end;
|
||||||
ETransportExecption = class(EServiceException) end;
|
|
||||||
|
ETransportExecption = class(EServiceException)
|
||||||
|
private
|
||||||
|
FExtendedErrorInfo : string;
|
||||||
|
public
|
||||||
|
property ExtendedErrorInfo : string
|
||||||
|
read FExtendedErrorInfo write FExtendedErrorInfo;
|
||||||
|
end;
|
||||||
|
|
||||||
EBaseRemoteException = class(EServiceException)
|
EBaseRemoteException = class(EServiceException)
|
||||||
private
|
private
|
||||||
|
@ -203,11 +203,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure THTTPTransport.DoSendAndReceive(ARequest, AResponse : TStream);
|
procedure THTTPTransport.DoSendAndReceive(ARequest, AResponse : TStream);
|
||||||
|
var
|
||||||
|
s, s2 : string;
|
||||||
|
ans : AnsiString;
|
||||||
|
e : ETransportExecption;
|
||||||
begin
|
begin
|
||||||
FConnection.Document.Clear();
|
FConnection.Document.Clear();
|
||||||
FConnection.Document.CopyFrom(ARequest,0);
|
FConnection.Document.CopyFrom(ARequest,0);
|
||||||
if not FConnection.HTTPMethod('POST',FAddress) then
|
if not FConnection.HTTPMethod('POST',FAddress) then begin
|
||||||
raise ETransportExecption.CreateFmt(SERR_FailedTransportRequest,[sTRANSPORT_NAME,FAddress]);
|
s := sysutils.Format(SERR_FailedTransportRequest,[sTRANSPORT_NAME,FAddress]);
|
||||||
|
s := s+sysutils.Format('Result code: %d, message: "%s"',[FConnection.ResultCode,Fconnection.ResultString]);
|
||||||
|
s2 := '';
|
||||||
|
if (FConnection.Document.Size > 0) then begin
|
||||||
|
SetLength(ans,FConnection.Document.Size);
|
||||||
|
Move(FConnection.Document.Memory^,ans[1],FConnection.Document.Size);
|
||||||
|
try
|
||||||
|
s2 := ans;
|
||||||
|
except
|
||||||
|
s2 := '';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
e := ETransportExecption.Create(s);
|
||||||
|
e.ExtendedErrorInfo := s2;
|
||||||
|
raise e;
|
||||||
|
end;
|
||||||
AResponse.CopyFrom(FConnection.Document,0);
|
AResponse.CopyFrom(FConnection.Document,0);
|
||||||
FConnection.Document.Clear();
|
FConnection.Document.Clear();
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user