Re: IdSMPT1->Send() throws exception without message

Giganews Newsgroups
Subject: Re: IdSMPT1->Send() throws exception without message
Posted by:  Remy Lebeau \(Indy Team\) (re…@lebeausoftware.org)
Date: Thu, 25 Feb 2010

"C.N.Taur" <nospam@nowhere.no> wrote in message
news:BF58F2B32BA5E340nospam@nowhere.no...

> which kind of error can cause an exception without an
> error message in the following code

Use the Exception's ClassName() method to determine which class type was
actually thrown.

>    catch (Exception *e)

Do not catch exceptions by pointer.  You need to catch them by reference
(better by 'const' reference) instead.

Try this:

try
{
    IdSMPT1->Connect();
    try
    {
        IdSMPT1->Send();
    }
    catch (const Exception &e)
    {
        Application->MessageBox(("[" + String(e.ClassName()) + "] " +
e.Message).c_str(), "Error sending mail", MB_OK);
        fprintf (fp, "Mail not sent. Error='[%s] %s'
",
String(e.ClassName()).c_str(), e.Message.c_str());
    }
}
catch (const Exception &e)
{
    Application->MessageBox (("[" + String(e.ClassName()) + "] " +
e.Message).c_str(), "Error connecting to the mail server", MB_OK);
    fprintf (fp, "Mail server unavailable. Error='[%s] %s'
",
String(e.ClassName()).c_str(), e.Message.c_str());
}

> Indy 10.1.5

That is a very old version of Indy 10.  The current version is 10.5.7.

--
Remy Lebeau (Indy Team)

Replies

In response to

IdSMPT1->Send() throws exception without message posted by C.N.Taur on Wed, 24 Feb 2010