#1 2018-04-21 02:35:01

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

TSynLog should ignore exceptions wrapped by try...except block

Hi ab,

By default TSynLog automatically logs any exceptions raised and this is a nice feature, but I think it should ignore exceptions wrapped by any empty 'try...except' block. I guess it's a common practice to use a try...except block to "eat" some exceptions, for example:

    try
      // do something and if any exception raises just ignore them.
    except
      // ignore all exceptions here.
    end;

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

Offline

#2 2018-04-21 21:28:56

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

Re: TSynLog should ignore exceptions wrapped by try...except block

It is another feature, at application level.

But IMHO exceptions should be exceptional.
See http://blog.synopse.info/post/2015/04/1 … -good-idea

Offline

#3 2018-04-22 02:41:02

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

Re: TSynLog should ignore exceptions wrapped by try...except block

@ab,

Sorry if I didn't make it clear - here I'm talking about the server side only. Like this:

function: TMyServerSideInterface.Method1: Integer;
begin
    // Point A
    try
      // do something.
    except // Point B
      // ignore all exceptions here.
    end;
end;

But the engine still logs exceptions raised between Point A and Point B.


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

Offline

#4 2018-04-26 16:14:49

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

Re: TSynLog should ignore exceptions wrapped by try...except block

Yes, it is as designed, and expected.
If the server code raises exceptions in "normal" process, then it is a design issue, and should be fixed.

On the server side, the exceptions should better always be cought by an "except...end" block, anyway.
So for your need, you could just remove exception logging from the SynLog levels.
But you will definitively miss a nice feature.

Offline

#5 2018-04-26 17:22:28

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

Re: TSynLog should ignore exceptions wrapped by try...except block

@ab,

There are times some exceptions can be ignored, for example, sending an email on the server-side, we might want to catch the 'internet error' and re-try again later.

On the other hand, it'll fix the issue if EchoCustom can tell TSynLog to ignore a given log entry.


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

Offline

#6 2018-04-26 17:28:54

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 336

Re: TSynLog should ignore exceptions wrapped by try...except block

@edwinsn I use TSynLog.Family.ExceptionIgnore.Add(ExceptionXXX), it is not useful for you ?


Esteban

Offline

#7 2018-04-27 03:11:30

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

Re: TSynLog should ignore exceptions wrapped by try...except block

@EMartin,

Oops! I missed that feature, thanks! I think it's enough for now.


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