RPC HELP TRPCBroker OnRPCBFailure Example: Difference between revisions
From VistApedia
Jump to navigationJump to search
Created page with "<h2>OnRPCBFailure Example</h2> For example, an application could define: Procedure HandleBrokerError(Sender: TObject); and then set: OnRPCBFailure := HandleBroker..." |
No edit summary |
||
| Line 32: | Line 32: | ||
'''finally''' | '''finally''' | ||
StrLoc.Free; | StrLoc.Free; | ||
'''end; | '''end;''' | ||
end;''' | '''end;''' | ||
Latest revision as of 17:42, 4 July 2015
OnRPCBFailure Example
For example, an application could define:
Procedure HandleBrokerError(Sender: TObject);
and then set:
OnRPCBFailure := HandleBrokerError;
NOTE: The initialization of the OnRPCBFailure property should be before the first call to the TRPCBroker component.
The following instance of an error handler will take the Message property of the exception and store it with a time date stamp into a file named Error.Log in the same directory with the application exe:
procedure TForm1.HandleBrokerError(Sender: TObject);
var
ErrorText: String;
Path: String;
StrLoc: TStringList;
NowVal: TDateTime;
begin
NowVal := Now;
ErrorText := TRPCBroker(Sender).RPCBError;
StrLoc := TStringList.Create;
try
Path := ExtractFilePath(Application.ExeName);
Path := Path + 'Error.Log';
if FileExists(Path) then
StrLoc.LoadFromFile(Path);
StrLoc.Add(FormatDateTime('mm/dd/yyyy hh:mm:ss ',NowVal) + ErrorText);
StrLoc.SaveToFile(Path);
finally
StrLoc.Free;
end;
end;