Rotina para pegar erros no Delphi

Delphi

31/03/2003

olá, gostaria de saber como faço para pegar todo o error do delphi e jogar para um arq. texto.


Edgriffo

Edgriffo

Curtidas 0

Respostas

Nildo

Nildo

31/03/2003

Segue aqui a unit completa...





unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure capturaErros(Sender: TObject; e: Exception);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.capturaErros(Sender: TObject; e: Exception);
var
arq: TStringList;
begin
arq := TStringList.create;
if fileExists(extractFilePath(paramStr(0)) + ´erros.txt´) then
arq.loadFromFile(extractFilePath(paramStr(0)) + ´erros.txt´);
arq.add (dateToStr(date) + ´ - ´ + (Sender as TComponent).name + ´ causou o seguinte erro: ´ + e.Message);
arq.saveToFile(extractFilePath(paramStr(0)) + ´erros.txt´);
arq.free;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
application.onException := CapturaErros;
end;

end.


GOSTEI 0
POSTAR