[ FranjoZG @ 01.03.2018. 13:13 ] @
Pokušavam iskoristiti Application.OnException da ne pišem 1001 try...except.

Sve to radi fino, ali, kako doznati što je točno uzrokovalo grešku.
Primer:
Code:

procedure TForm1.FormCreate(Sender: TObject);
begin
   Application.OnException := AppException;
end;
...
procedure TForm1.AppException(Sender: TObject; E: Exception);
begin
  ShowMessage('Gr 2' + #13 + Sender.ClassName + #13 + e.ClassName + #13 + e.Message);
end;
...
procedure TForm1.Button1Click(Sender: TObject);
var a,b,c: double;
begin
   a := 10;
   b := 100;
   c := 0;
   while a > -5 do begin
     c := b / a;
     Memo1.Lines.Append(FloatToStr(c));
     a := a - 1;
   end;
end;

Namjerno je napravljeno da izazove djelenje sa nulom. Program uredno uđe u AppException proceduru, ali Sender je Form1.
Postoji li mogučnost da se dobije kao sender procedura Button1Click, broj retka koda ili nešto slično da se zna što je izazvalo grešku? Ovako je neiskoristivo, nije mi od pomoće ako znam da je negdje došlo do dijelenja sa nulom!
[ savkic @ 01.03.2018. 14:20 ] @
Za to ti treba StackTrace info, pogledaj http://docwiki.embarcadero.com....SysUtils.Exception.StackTrace da li ti moze pomoci.
Inace ako trazis logovanje exceptiona sa detaljima onda JEDI nije lose resenje.
[ FranjoZG @ 01.03.2018. 14:57 ] @
U međuvremenu našao zgodno rješenje, malo doraditi...
Ako koga zanima:

http://www.jirihajek.net/delphi/ExceptLog.htm

Muči me kako kodove greške pretvoriti u stvarne opise. Za prethodni primjer mi napravi (nakon malih izmjena koda i zamjene '@' -> '//'). Petlju sam u međuvremenu prebacio u funkciju "Racunaj". Trebalo bi i skratiti popis na recimo prvih 5, ostalo tak i tak nema smisla.


01.03.2018. 15:24:25 New exception:
Exception code: 3221225614
Exception flags: 2
Number of parameters: 1
Module Unit1.pas Routine //Unit1//TForm1//racunaj Line 70 Find error: 0045DE88
call stack - 0 : Module Unit1.pas Routine //Unit1//TForm1//Button1Click Line 49 Find error: 0045DDE5
call stack - 1 : Routine //Controls//TWinControl//WndProc Find error: 0043E96C
call stack - 2 : Routine //Stdctrls//TButtonControl//WndProc Find error: 00429AB5
call stack - 3 : Routine //Controls//DoControlMsg Find error: 0043EABC
call stack - 4 : Routine //Controls//TWinControl//WndProc Find error: 0043E96C
call stack - 5 : Routine //Forms//TCustomForm//WndProc Find error: 0044FB58
call stack - 6 : Routine //Controls//TWinControl//MainWndProc Find error: 0043E093
call stack - 7 : Routine //Classes//StdWndProc Find error: 0041C20E
call stack - 8 : (no debug info) Find error: 74E7E0B7
call stack - 9 : (no debug info) Find error: 74E88845
call stack - 10 : (no debug info) Find error: 74E8B141
call stack - 11 : (no debug info) Find error: 74E8A898
call stack - 12 : (no debug info) Find error: 74E6B957
call stack - 13 : (no debug info) Find error: 6EC86930
call stack - 14 : (no debug info) Find error: 6EC9C147
call stack - 15 : (no debug info) Find error: 74E7E0B7
call stack - 16 : (no debug info) Find error: 74E88845
call stack - 17 : (no debug info) Find error: 74E8B141
call stack - 18 : (no debug info) Find error: 74E88336
call stack - 19 : (no debug info) Find error: 74E6F387
call stack - 20 : Routine //Controls//TWinControl//DefaultHandler Find error: 0043EA68
call stack - 21 : Routine //Controls//TWinControl//WndProc Find error: 0043E96C
call stack - 22 : Routine //Stdctrls//TButtonControl//WndProc Find error: 00429AB5
call stack - 23 : Routine //Classes//StdWndProc Find error: 0041C20E
call stack - 24 : (no debug info) Find error: 74E7E0B7
call stack - 25 : (no debug info) Find error: 74E88845
call stack - 26 : (no debug info) Find error: 74E8B141

[ FranjoZG @ 04.03.2018. 09:48 ] @
Malo sam se igrao sa primjerom i procedurama. Radi dobro za greške tima npr: "Folating point division by zero". Javi točnu specifikaciju greške (Modulet Unit1.pas Routine...), proceduru i liniju:

04.03.2018. 10:42:52 New exception:
5Exception code: 3221225614
Exception flags: 2
Number of parameters: 1
Module Unit1.pas Routine //Unit1//TForm1//Button1Click Line 36 Find error: 0045DE30
call stack - 0 : Routine //Controls//TControl//Click Find error: 0043AEBA
call stack - 1 : Routine //Controls//TWinControl//WndProc Find error: 0043E96C
call stack - 2 : Routine //Stdctrls//TButtonControl//WndProc Find error: 00429AB5
call stack - 3 : Routine //Controls//DoControlMsg Find error: 0043EABC
call stack - 4 : Routine //Controls//TWinControl//WndProc Find error: 0043E96C
call stack - 5 : Routine //Forms//TCustomForm//WndProc Find error: 0044FB58
call stack - 6 : Routine //Controls//TWinControl//MainWndProc Find error: 0043E093
call stack - 7 : Routine //Classes//StdWndProc Find error: 0041C20E
call stack - 8 : (no debug info) Find error: 74E7E0B7
call stack - 9 : (no debug info) Find error: 74E88845
call stack - 10 : (no debug info) Find error: 74E8B141
call stack - 11 : (no debug info) Find error: 74E8A898
call stack - 12 : (no debug info) Find error: 74E6B957
call stack - 13 : (no debug info) Find error: 6EC86930
call stack - 14 : (no debug info) Find error: 6EC9C147
call stack - 15 : (no debug info) Find error: 74E7E0B7
call stack - 16 : (no debug info) Find error: 74E88845
call stack - 17 : (no debug info) Find error: 74E8B141
call stack - 18 : (no debug info) Find error: 74E88336
call stack - 19 : (no debug info) Find error: 74E6F387
call stack - 20 : Routine //Controls//TWinControl//DefaultHandler Find error: 0043EA68
call stack - 21 : Routine //Controls//TWinControl//WndProc Find error: 0043E96C
call stack - 22 : Routine //Stdctrls//TButtonControl//WndProc Find error: 00429AB5
call stack - 23 : Routine //Classes//StdWndProc Find error: 0041C20E
call stack - 24 : (no debug info) Find error: 74E7E0B7
call stack - 25 : (no debug info) Find error: 74E88845
call stack - 26 : (no debug info) Find error: 74E8B141


Za greške koje su meni najvažnije ("Access violation...") ne javi proceduru niti liniju koda. Primer:
Code:

procedure TForm1.Button2Click(Sender: TObject);
var tl: tstringlist;
begin
   tl.Append('adf');
end;

javi sljedeće:

04.03.2018. 10:44:31 New exception:
0Exception code: 3221225477
Exception flags: 2
Number of parameters: 2
(no debug info) Find error: 00441BB1
call stack - 0 : Routine //Controls//TWinControl//ConstrainedResize Find error: 00441F93
call stack - 1 : Routine //Classes//TStrings//Append Find error: 00415BB6
call stack - 2 : Routine //Controls//TWinControl//WndProc Find error: 0043E96C
call stack - 3 : Routine //Stdctrls//TButtonControl//WndProc Find error: 00429AB5
call stack - 4 : Routine //Controls//DoControlMsg Find error: 0043EABC
call stack - 5 : Routine //Controls//TWinControl//WndProc Find error: 0043E96C
call stack - 6 : Routine //Forms//TCustomForm//WndProc Find error: 0044FB58
call stack - 7 : Routine //Controls//TWinControl//MainWndProc Find error: 0043E093
call stack - 8 : Routine //Classes//StdWndProc Find error: 0041C20E
call stack - 9 : (no debug info) Find error: 74E7E0B7
call stack - 10 : (no debug info) Find error: 74E88845
call stack - 11 : (no debug info) Find error: 74E8B141
call stack - 12 : (no debug info) Find error: 74E8A898
call stack - 13 : (no debug info) Find error: 74E6B957
call stack - 14 : (no debug info) Find error: 6EC86930
call stack - 15 : (no debug info) Find error: 6EC9C147
call stack - 16 : (no debug info) Find error: 74E7E0B7
call stack - 17 : (no debug info) Find error: 74E88845
call stack - 18 : (no debug info) Find error: 74E8B141
call stack - 19 : (no debug info) Find error: 74E88336
call stack - 20 : (no debug info) Find error: 74E6F387
call stack - 21 : Routine //Controls//TWinControl//DefaultHandler Find error: 0043EA68
call stack - 22 : Routine //Controls//TWinControl//WndProc Find error: 0043E96C
call stack - 23 : Routine //Stdctrls//TButtonControl//WndProc Find error: 00429AB5
call stack - 24 : Routine //Classes//StdWndProc Find error: 0041C20E
call stack - 25 : (no debug info) Find error: 74E7E0B7
call stack - 26 : (no debug info) Find error: 74E88845


Ima li tko ideju kako to rijšiti i može li se uopće?
[ savkic @ 04.03.2018. 13:29 ] @
Probaj drugi exception library, JclDebug ili MadExcept.
[ tkaranovic @ 04.03.2018. 16:17 ] @

Ako je 64-bitna app omda moze samo madexcept.
[ FranjoZG @ 04.03.2018. 19:20 ] @
Istina, madExcept radi dobro, našao i skinuo. Toplo preporučam. JCLDebug sam isprobao ranije, ne daje broj linije kod svih exception-a, madExcept daje.