procedure TLoggedDataAbstractService.DataAbstractServiceDeactivate(const aClientID: TGUID; aSession: TROSession);
var
vException: TObject;
begin
inherited;
vException := ExceptObject;
if (vException is Exception) and not(vException is EFpNonCriticalException) then
begin
// Log exception...
ServiceLogger.SendException(vException as Exception);
end;
end;
How can I log all the exceptions sent back to the client, in a .NET server?
I’m afraid there is no way to implement similar code in a .NET server. You can only override existing methods of the DataAbstractService like GetData and UpdateData with a code like
public override int ExecuteCommandEx(string commandName, DataParameter[] inputParameters, out DataParameter[] outputParameters)
{
try
{
return base.ExecuteCommandEx(commandName, inputParameters, out outputParameters);
}
catch (Exception e)
{
// Log exception and rethrow it
throw;
}
}
public override Binary UpdateData(Binary serializedDelta)
{
try
{
return base.UpdateData(serializedDelta);
}
catch (Exception e)
{
// Log exception and rethrow it
throw;
}
}
public override Binary GetData(string[] tableNames, TableRequestInfo[] requestInfo)
{
try
{
return base.GetData(tableNames, requestInfo);
}
catch (Exception e)
{
// Log exception and rethrow it
throw;
}
}
Ok, thanks. This means I have to surround every single call to every single method in the server, with logging code for exceptions. Not a problem, but not the cleanest solution either, . Hopefully you can create an event (possibly where you catch and serialize the exception to send it back to the client), where we can do the logging of the exception object (which I believe issue #82080 is for, ).
Yes, you are right. The issue #82080 is for adding an event that will be raised when an unhandled exception was raised during the service method execution. This event will provide a centralized place where all such exceptions can be logged.
Unfortunately this change won’t be in the upcoming RTM, but for sure it will be present in one of the first post-release Beta builds
Agreed for sure! We have a lot of stuff using RO/DA so it’s quite a lot to update/test when we install the latest version, but I had urgent need for this event