请问程序怎样捕捉一个异常,然后写入日志文件。重要的是怎样使程序自动继续运行?

解决方案 »

  1.   

    try
      ...
    except e: Exception
      ...         // Save log
    end;
      

  2.   

    同意up,在except后写你要执行的程序。
      

  3.   

    use Application.OnException (TApplication) or TApplicationEvents.OnException procedure (Sender: TObject; E: Exception) of Object;
    begin
      //Save Log here
    end;
      

  4.   

    try
      ...//循环
    except
      ...//save log
      continue;//继续循环
    end;
      

  5.   

    while XXXXXX do
    begin
      try
        ...;
        ...;
      except
        Logfile.WriteLog ('this is log text.');
        //如果后面动作不用执行的话,可以做下面动作
        Continue;//这样就不会退出循环,继续下个循环
      end;
      ...;
      ...;
    end;