Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
prog:lazarus:classes:exceptions [26/09/2019 20:15]
thierry créée
prog:lazarus:classes:exceptions [13/05/2021 15:37] (Version actuelle)
thierry [Application.CaptureException]
Ligne 1: Ligne 1:
-====== ​Les Exceptions dans Lazarus ​======+====== ​Exception & Erreurs====== 
 +===== La class ===== 
 +<code delphi>​ 
 +   ​Exception = class(TObject) 
 +    public 
 +      constructor Create(const msg : string); 
 +      constructor CreateFmt(const msg : string; const args : array of const); 
 +      constructor CreateRes(ResString:​ PString); 
 +      constructor CreateResFmt(ResString:​ PString; const Args: array of const); 
 +      constructor CreateHelp(const Msg: string; AHelpContext:​ Longint); 
 +      constructor CreateFmtHelp(const Msg: string; const Args: array of const; 
 +        AHelpContext:​ Longint); 
 +      constructor CreateResHelp(ResString:​ PString; AHelpContext:​ Longint); 
 +      constructor CreateResFmtHelp(ResString:​ PString; const Args: array of const; 
 +        AHelpContext:​ Longint); 
 +      Function ToString : String; override; ​  
 +      property HelpContext : longint read fhelpcontext write fhelpcontext;​ 
 +      property Message : string read fmessage write fmessage; 
 +   ​end;​ 
 +</​code>​ 
 ===== Déclencher une Exception ===== ===== Déclencher une Exception =====
 <code delphi> <code delphi>
Ligne 7: Ligne 27:
 </​code>​ </​code>​
  
-===== Capturer une Exception =====+===== Try/Except : Capturer une Exception =====
 <code delphi> <code delphi>
 try try
Ligne 18: Ligne 38:
 end; end;
 </​code>​ </​code>​
 +===== Application.CaptureException =====
 +Apparement TApplication aurait une propertir CaptureException (public) pour gérer les exceptions.... a creuser.
 +<code delphi>
 +procedure TApplication.RunLoop;​
 +begin
 +  repeat
 +    if CaptureExceptions then
 +      try // run with try..except
 +        HandleMessage;​
 +      except
 +        HandleException(Self);​
 +      end
 +    else
 +      HandleMessage;​ // run without try..except
 +  until Terminated;
 +end;
 +</​code>​
 +===== Liste des erreurs Windows =====
 +La liste des erreurs Windows se trouve dans le fichier ''​...\fpcsrc\rtl\win\wininc\errors.inc''​
 +