Convert Connect & Send Delphi Exceptions to meaningful text

Giganews Newsgroups
Subject: Convert Connect & Send Delphi Exceptions to meaningful text
Posted by:  Tom (no…@none.com)
Date: Fri, 13 Jun 2008

With Indy 9 and Delphi, how can I convert an exception to a meaningful error
message rather than just a numeric code?

I have not idea if the code below is the right approach.

    try
      idSMTP.Connect(1000);
      idSMTP.Send(MailMessage);
    except on E:Exception do
      begin
        ErrorResult := GStack.LastError; // for WinSock errors
        if ErrorResult <> 0 then
          Errm := GStack.WSTranslateSocketErrorMsg(ErrorResult)
        else
          begin
              ErrorResult := idSMTP.LastCmdResult.NumericCode; // for server
error codes
              if ErrorResult <> 0 then
                IS THERE A CALL TO translate an idSMTP Numeric code to
text???
            end;

        if (Errm = '') then
          ShowMessage( 'ERROR sending mail: ' + E.Message)
        else
          ShowMessage( 'ERROR sending mail: ' + Errm);
      end; // Except

Replies