#1 2014-07-29 08:04:12

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Why the sqlite3 exceptions are eaten in TSQLRestServerDB.Commit?

Arnaud,

Why the sqlite3 exceptions are eaten in TSQLRestServerDB.Commit, as shown below?

procedure TSQLRestServerDB.Commit(SessionID: cardinal=1);
begin
  inherited Commit(SessionID); // reset fTransactionActive + write all TSQLVirtualTableJSON
  try
    DB.Commit;
  except
    on ESQLite3Exception do
      ; // just catch exception
  end;
end;

I think there are many cases we need the flexibility of being able to  catch the sqlite 3 exceptions and handle accordingly.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2014-07-29 08:43:19

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Why the sqlite3 exceptions are eaten in TSQLRestServerDB.Commit?

Found another place that also eats the sqlite errors silently:

TSQLRestServerDB.EngineExecute();
Begin
...
      {$ifdef WITHLOG}
      DB.Log.Log(sllError,'% for %',[E,aSQL],self);
      {$else}
      LogToTextFile('TSQLRestServerDB.EngineExecute: '+RawUTF8(E.Message)+#13#10+aSQL);
      {$endif}

...
end;

I think when withlog is not defined, just call raise, give our programs the chance to get the exact error and handle accordingly. Handling errors with exceptions, instead of IF statements, are a commonly accepted concept, IIRC.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#3 2014-07-29 17:54:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Why the sqlite3 exceptions are eaten in TSQLRestServerDB.Commit?

Both Commit and RollBack are procedures, so do not return any error boolean flag.
Perhaps it is an issue, but their execution is expected to continue.

EngineExecute returns an error boolean flag.

In all case, any Exception would be logged on the server side.

Online

#4 2014-07-30 05:53:35

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Why the sqlite3 exceptions are eaten in TSQLRestServerDB.Commit?

Arnaud,

Is there an option to get over the currently forced logging and let us handle the errors?


ab wrote:

Both Commit and RollBack are procedures, so do not return any error boolean flag.
Perhaps it is an issue, but their execution is expected to continue.

EngineExecute returns an error boolean flag.

In all case, any Exception would be logged on the server side.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#5 2014-07-30 07:49:48

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Why the sqlite3 exceptions are eaten in TSQLRestServerDB.Commit?

edwinsn wrote:

Is there an option to get over the currently forced logging and let us handle the errors?

Not at TSQLRest level.
Just at SynSQlite3 level.

Online

#6 2014-07-30 10:17:43

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Why the sqlite3 exceptions are eaten in TSQLRestServerDB.Commit?

ab wrote:
edwinsn wrote:

Is there an option to get over the currently forced logging and let us handle the errors?

Not at TSQLRest level.
Just at SynSQlite3 level.

So would you accept this as an option to disabled the logging and let us handle exceptions, at TSQLRest level?


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#7 2014-07-30 11:57:32

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Why the sqlite3 exceptions are eaten in TSQLRestServerDB.Commit?

This would be a breaking change of all TSQLRest interfaces behavior.
So I do not think it is suitable nor urgent.

Online

#8 2014-07-30 15:05:20

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Why the sqlite3 exceptions are eaten in TSQLRestServerDB.Commit?

Ok. So with the current implementation, what do you think to be the best way of getting the real sqlitedb errors? Like this?

if myRestServer.Add(...) < 1 then
beign
  GetTheLatestServerLogEntry() //how?
end

How? Your help will be appreciated!

Last edited by edwinsn (2014-07-30 15:05:47)


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#9 2014-07-30 17:28:17

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Why the sqlite3 exceptions are eaten in TSQLRestServerDB.Commit?

Sadly, in a multi-threaded server, and even more from a remote client, such a pattern would not work.

You can't be sure that there won't be any other error between the Add() and the GetTheLatestServerLogEntry().

Online

#10 2014-07-31 04:05:10

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Why the sqlite3 exceptions are eaten in TSQLRestServerDB.Commit?

Arnaud,

I am not limited to the last server log entry, what I want is to get notified when there is a database error and know where to look for the error messages that really tell the true problem.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB