Autor Beitrag
Smartie
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 205



BeitragVerfasst: Do 28.04.05 09:43 
Hallo,

ich möchte mich nun daran machen, mehr und mehr Fehler abzufangen.
Ind er Hilfe hab ich z.b. folgendes gefunden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
try
 ...
except
  on EZeroDivide do HandleZeroDivide;
  on EOverflow do HandleOverflow;
  on EMathError do HandleMathError;
end;


ok, soweit klar. Jetzt meien Frage, kann ich auch "Einfach nur" meine eigene Behandlungsweise setzen, egal welcher Fehler auftritt?

So in der Art z.B.:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
try
 ...
except
  ERROR_String := Fehler7;
  showMessage('Es ist ein Fehler Aufgetreten!' + Fehler7);
end;



Lieben Gruß

Smartie
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Do 28.04.05 09:48 
Hallo,

das kannst du so machen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
try
  { dein Cose}
except
  on e : Exception do begin
    ShowMessage('Ein Fehler ist aufgetreten. Systemmeldung: ' + e.Message);
  end;
end;


Hoffe du hast das so gemeint.

Gruß
Klabautermann
Smartie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 205



BeitragVerfasst: Do 28.04.05 10:04 
Fast, nur ohne das e.Message


Tausend Dank

Smartie
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Do 28.04.05 10:50 
user profile iconSmartie hat folgendes geschrieben:
Fast, nur ohne das e.Message

Dann kannst du auch das "on e : exception do" weg lassen. Also einfach:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
try
  { dein Cose}
except
  ShowMessage('Ein Fehler ist aufgetreten.');
end;


Gruß
Klabautermann
Smartie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 205



BeitragVerfasst: Do 28.04.05 12:02 
Irgendwie spintn er da volkomme nrum. Muß ich irgendeine bestimmte Unit einbinden, und habs verpeilt? *Ungläubig schaut*

Lieben Gruß

Smartie
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Do 28.04.05 12:06 
Hi,
user profile iconSmartie hat folgendes geschrieben:
Irgendwie spintn er da volkomme nrum. Muß ich irgendeine bestimmte Unit einbinden, und habs verpeilt? *Ungläubig schaut*

nein, da musst du ncihts einbinden. In wie weit "Spinnt er". Lass am besten mal ein wenig Code sehen.

Gruß
Klabautermann
Smartie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 205



BeitragVerfasst: Do 28.04.05 12:09 
Hier isses:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
[blah blah]

        try
         {mein code}
        except  
          begin
             ERROR_String := ERROR_Konv2;  //Konvertierung nicht möglich
          end;
      // Ende des Konvertierungsblocks

    end;


end;

{-----------------------------------------------------------------------------
  Procedure : Button1
  Version   : Alfa

  Resultat    : Button zum Daten verarbeiten
-----------------------------------------------------------------------------}


procedure TForm1.Button1Click(Sender: TObject); // Unit1.pas(268): Anweisung erwartet, aber 'PROCEDURE' gefunden
var a : Integer;
begin
    if datei = '' then
    begin

[blah blah]
Smartie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 205



BeitragVerfasst: Do 28.04.05 12:24 
Ok, habs gefunden!

Ich hab einfach das "end;" vom try vergessen ich Hirsch!

Herzlichen Dank und Lieben Gruß

Smartie