domingo, 12 de abril de 2015

delphi try catch

var
fic: textfile;


(...)
 
try
  j:=0;
  i:=1 div j;

  except
  on E : Exception do
  begin

  AssignFile (fic,'logerrores.txt');

  if FileExists('logerrores.txt')=false then
  begin
    ReWrite(fic);
  end
  else
  begin
    Append(fic);
  end;

  writeln(fic,datetostr(now()) + ' ' + timetostr(now()));
  writeln(fic,'-------------------------------------------------------------------');
  writeln(fic,'Exception class name = '+E.ClassName);
  writeln(fic,'Exception message = '+E.Message);
  writeln(fic,'');
  CloseFile (fic);
  end;


.

No hay comentarios: