Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Exception u Delphi 2007

[es] :: Pascal / Delphi / Kylix :: Exception u Delphi 2007

[ Pregleda: 921 | Odgovora: 6 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

FranjoZG
Franjo Popović
Programer
Zagreb

Član broj: 328819
Poruke: 245
*.adsl.net.t-com.hr.



+2 Profil

icon Exception u Delphi 200701.03.2018. u 13:13 - pre 31 meseci
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!
 
Odgovor na temu

savkic
Igor Savkić

Moderator
Član broj: 92186
Poruke: 2638



+69 Profil

icon Re: Exception u Delphi 200701.03.2018. u 14:20 - pre 31 meseci
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.
 
Odgovor na temu

FranjoZG
Franjo Popović
Programer
Zagreb

Član broj: 328819
Poruke: 245
*.adsl.net.t-com.hr.



+2 Profil

icon Re: Exception u Delphi 200701.03.2018. u 14:57 - pre 31 meseci
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

 
Odgovor na temu

FranjoZG
Franjo Popović
Programer
Zagreb

Član broj: 328819
Poruke: 245
*.cust.tele2.hr.



+2 Profil

icon Re: Exception u Delphi 200704.03.2018. u 09:48 - pre 31 meseci
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?
 
Odgovor na temu

savkic
Igor Savkić

Moderator
Član broj: 92186
Poruke: 2638



+69 Profil

icon Re: Exception u Delphi 200704.03.2018. u 13:29 - pre 31 meseci
Probaj drugi exception library, JclDebug ili MadExcept.
 
Odgovor na temu

tkaranovic
Tomislav Karanović
Beograd

Član broj: 220507
Poruke: 277
*.adsl-a-1.sezampro.rs.



+13 Profil

icon Re: Exception u Delphi 200704.03.2018. u 16:17 - pre 31 meseci

Ako je 64-bitna app omda moze samo madexcept.
 
Odgovor na temu

FranjoZG
Franjo Popović
Programer
Zagreb

Član broj: 328819
Poruke: 245
*.cust.tele2.hr.



+2 Profil

icon Re: Exception u Delphi 200704.03.2018. u 19:20 - pre 31 meseci
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.
 
Odgovor na temu

[es] :: Pascal / Delphi / Kylix :: Exception u Delphi 2007

[ Pregleda: 921 | Odgovora: 6 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.