我們使用Delphi 7運行的軟件通過電子郵件生成併發送報告給各個利益相關者。在每天傳輸的大約30-40個報告中,每天2-4個不同的報告因爲例外而失敗:「EIdConnClosedGracefully」疑難解答EIdConnClosedGracefully異常?
我試圖追蹤爲什麼會發生這種情況,以及如何在代碼中捕獲此信息。下面是我們到目前爲止有:
try
// Code that Populates "mess" (a tIdMessage variable)
if (not nSMTP.Connected) then
begin
nSMTP.Connect;
end;
try
nSMTP.Send(mess);
except on E : Exception do
begin
resend := E.Message;
// AutoReports_ExceptionMessage is a string that holds the Exception message
AutoReports_ExceptionMessage := 'Attempt #1: ' + resend;
end;
end;
if (resend <> '') then // If there is an exception triggered, resend the email
begin
try
nSMTP.Send(mess);
except on E : Exception do
begin
resend := E.Message;
AutoReports_ExceptionMessage := 'Attempt #2: ' + resend;
end;
end;
end
finally
mess.Free;
end;
此外,當,EIdConnClosedGracefully是觸發時,它總是顯示「嘗試#2:連接關閉擺好。」並從來沒有「嘗試#1:連接關閉優雅地」
任何建議?
這是一個正常的異常...黑體書寫的源代碼。你必須忽略它。 –