Question: after I raise an exception, can I stop it for propagation from its own constructor? consider the following code:
unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TMyErrorClass = class(Exception) constructor Create(aMsg:String); end; TForm2 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.dfm} procedure TForm2.FormCreate(Sender: TObject); begin // raise TMyErrorClass.Create('test'); end; { TMyErrorClass} constructor TMyErrorClass.Create(aMsg: String); begin {$IFDEF DEBUG} Showmessage(aMsg); {$ELSE} //here I want to 'kill' the exception {$ENDIF} end; end.
After calling the flight, how can I end the Exception without adding try except / finally, where do I raise an exception?
LE: I have an application that has almost 2,000 raises like this ... and I'm trying to find an alternative solution for writing errors for it ....
source share