Hello,
I'm asking for Delphi native,not Prism(net).
This is my code:
raise Exception.Create('some test');
Undeclarated idenitifier "Exception".
Where's the problem,how do I throw/raise exceptions?
Hello,
I'm asking for Delphi native,not Prism(net).
This is my code:
raise Exception.Create('some test');
Undeclarated idenitifier "Exception".
Where's the problem,how do I throw/raise exceptions?
You are using SysUtils aren't you? Exception is declared in there IIRC.
You may need to add sysutils to the uses clause, it is not built in and is optional according to Delphi in a nutshell.
The exception class "Exception" is declared in the unit SysUtils. So you must add "SysUtils" to your uses-clause.
uses
SysUtils;
procedure RaiseMyException;
begin
raise Exception.Create('Hallo World!');
end;
Remember to add SYSUTILS to your uses units.
I also suggest you to a nice way to keep track of categories, formats of messagges and meaning of exception:
Type TMyException=class
public
class procedure RaiseError1(param:integer);
class procedure RaiseError2(param1,param2:integer);
class procedure RaiseError3(param:string);
end;
implementation
class procedure TMyException.RaiseError1(param:integer);
begin
raise Exception.create(format('This is an exception with param %d',[param]));
end;
//declare here other RaiseErrorX
A simple way of using this is:
TMyException.RaiseError1(123);