EgonHugeist wrote: ↑04.11.2020, 09:51
marsupilami wrote: ↑04.11.2020, 06:37
I thought that we agreed that the ADO driver can raise EZSQLExceptions/EDatabaseError and EOleExceptions as well as long as we document it? Why do we do that kind of rewrapping? We really do need to document design decisions.
Well we can document everything ... does it make sence?? Is it handy for the users? I don't think so. The more look to point 2 below.
It makes sense. We do what we can do without shooting ourselves in the head - or in our foot. Exceptions can be caught by the user so he can log them if he wants to. I am pretty sure, they even can be simply logged to the same logger. In the world of ADO logging errors automatically simply doesn't make sense. One could also say it is a technical limitation.
Also there always are Exceptions that we don't log. Again: What do we do about exceptions from other units? Our own core Exceptions are not of the EZSqlThrowable type. The same goes for other error conditions. Examples are EOutOfMemory, EAccessViolation, EZeroDivide. These are harsh conditions but there might be more subtle ones. So - which Exceptions are we going to log then? Because if we want to log all Errors, we also have to log these Exceptions?
EgonHugeist wrote: ↑04.11.2020, 09:51
Some more examples:
1. the compiler silently adds some lines around the method calls. But there is a trivial thing missing:
Code: Select all
if HResult <> S_OK (zero) then call @CheckAutoResult
means each call steps though houndreds of asm lines in CheckAutoResult.
Erm - I disagree. As long as there is no Exception to be transported HResult will be S_OK and so @CheckAutoResult doesn't get called. So in a usual use case, there is a maximum of one more integer comparision combined with a jump. For me this hardly is a performance penalty. I seem to remember that the X86 architecture has a combined instruction for that kind of code (JNZ / JZ).
EgonHugeist wrote: ↑04.11.2020, 09:51
2. We have a
LoggingMechanism i.e. IZLoggingListener. How do you think we can log errors without catching the Exception???
The loggs a a general design and have nothing todo which API is used in background. OleException or others it doesn't matter. Of cause you can also document the proxy can't log errors... just my two cents, Jan.
Well - the logger doesn't get used on a regular basis. Again - if there are Exceptions to log, the user can do it himself. The logger is interesting as a tool for debugging, checking what Zeos sends to the database. Not so much as an error log.
If we really really really needed this, we could have something like this:
Code: Select all
type
TExecuteSQLFunc = procedure (SQL: String): IZResultSet;
TSomeStatement = class(...)
FExecSQL: TExecuteSQLFunc;
function InternalExecuteSql(SQL: String): IZResultSet;
function InternalExecuteSqlAndLog(SQL: String): IZResultSet;
function ExecuteSQL(SQL: String): IZResultSet;
procedure EnableLogging(Enable: Boolean);
end;
function TSomeStatement.InternalExecuteSql(SQL: String): IZResultSet;
begin
// do the execution of the SQL here...
end;
function TSomeStatement.InternalExecuteSqlAndLog(SQL: String): IZResultSet;
begin
try
Result := InternalExecuteSql(SQL): IZResultSet;
except
on E: Exception do begin
LogMessage(E.Message);
raise;
end;
end;
end;
function TSomeStatement.ExecuteSQL(SQL: String): IZResultSet;
begin
Result := FExecSQL(SQL);
end;
procedure TSomeStatement.EnableLogging(Enable: Boolean);
begin
if Enable then
FExecSQL := InternalExecuteSqlAndLog
else
FExecSQL := InternalExecuteSql;
end;
This would spare us the setup and tear down the Exception handling. It will cost us one more jump and possibly one or two _Addref / _DecRef cycles. But maybe not.
Given all this, currently I don't intend to give up an easy to use tool for
safe programming. Everything else would make my life much much harder. I simply don't see the benefit for investing my time there. With the current design decisions I can be pretty sure that memory management and exception handling will not make programs fail silently or in weird ways because I chose some well tesed mechanisms there, that actually help me concentrate on the core of my problem. And being able to concentrate on the core of my problem keeps me productive and helps me sleep better at night.
So yes - for the proxy driver it will be a technical limitation that it cannot log errors and that it will raise EOleError type Exceptions if anything happens on the level of the server or SOAP. Anybody who dislikes these design decisions is welcome to spend time on adding to the driver.
My primary goal currently is to get it to work. If I ever have the time for it, I can think about speeding it up later on.