Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi ExceptionHandling in der Projektdatei (https://www.delphipraxis.net/32305-exceptionhandling-der-projektdatei.html)

Shaman 21. Okt 2004 14:17


ExceptionHandling in der Projektdatei
 
Hallo zusammen

Ich möchte eine globale Fehlerbehandlung realisieren. Dazu setze ich direkt im dpr-File an:

Delphi-Quellcode:
program Project1;

uses
  Forms, SysUtils, Dialogs,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

procedure GlobalExceptionHandler(Sender: TObject; E: Exception);
begin
  ShowMessage('Globaler ExceptionHandler');
end;

begin
  Application.Initialize;
  @Application.OnException:= @GlobalExceptionHandler;
  raise Exception.Create('Irgendein Fehler halt');
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
Doch der ExceptionHandler wird nie aufgerufen. Warum? :gruebel:

Gruss
Shaman

Dax 21. Okt 2004 14:19

Re: ExceptionHandling in der Projektdatei
 
Gib der Application doch aus TForm.Create -- oder lass mal auf beiden Seiten das "@" weg.

Shaman 21. Okt 2004 14:24

Re: ExceptionHandling in der Projektdatei
 
Dann bringt er inkompatible Typen, weil GlobalExceptionHandler keine Methode ist...

Dax 21. Okt 2004 14:24

Re: ExceptionHandling in der Projektdatei
 
Dann mach es zur Methode, z.B. in einer TForm, oder einer eigenen TApplication-Klasse.

Shaman 21. Okt 2004 14:40

Re: ExceptionHandling in der Projektdatei
 
Wenn eine Exception von einer Unit ausgelöst wird, funktioniert es, aber nicht wenn ein Fehler in der Projektdatei selber auftritt... :?:


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:37 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz