🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #839

Re: Assertion Error while sending email

#839
From: Remy Lebeau (TeamB)
Date: Thu, 02 Aug 2007 18:40
99 lines
3925 bytes
"JLoz" <jfsierra@excite.com> wrote in message
news:46b10f2b$1@newsgroups.borland.com...

> Below is the stack trace you asked for.

That stack trace is showing a completely different error than the one you
have been describing.

> The "Cannot decode Response" error occurs after the fact
> as I have a try finally around this and it happens when I try
> to disconnect by using this code

Based on what the stack trace shows, what appears to be happening is that
the code is crashing while sending a login command to the server, so there
is likely unprocessed data from the server being left in the connection's
InputBuffer, such that when you call Disconnect() later, it sends a QUIT
command to the server and then ends up reading the unprocessed data from the
earlier command and fails.

>       if (!UpperCase(E.Message).Pos("RANGE CHECK ERROR")) {

That is not the best way to check for a specific exception type.  You should
be checking for the ERangeError class specifically instead, ie:

    catch (const Sysutils::ERangeError& E)
    {
        // why do you ignore this type of error?
    }
    catch (const Sysutils::Exception& E)
    {
        err = E.Message;
        Header.Set("Error", E.Message);
        Header.Set("Result", "0");
    }

Or:

    catch (const Sysutils::Exception& E)
    {
        if( dynamic_cast<const ERangeError*>(&E) == NULL )
        {
            err = E.Message;
            Header.Set("Error", E.Message);
            Header.Set("Result", "0");
        }
    }

Or:

    catch (const Sysutils::Exception& E)
    {
        if( !E.InheritsFrom(__classid(ERangeError)) )
        {
            err = E.Message;
            Header.Set("Error", E.Message);
            Header.Set("Result", "0");
        }
    }


>   if(err != "") throw Sysutils::Exception(AnsiString(err));

You should be re-throwing the original exception, not creating a new one.
You lose the original error information that way.

Try something more like this code instead:

    try
    {
        IdSMTP1->Connect();
        try
        {
            IdSMTP1->Send(IdMessage1);
        }
        __finally
        {
            IdMessage1->Clear();
            IdSMTP1->Disconnect();
        }
    }
    catch (const Sysutils::ERangeError & E)
    {
        // ignore ...
    }
    catch (const Sysutils::Exception& E)
    {
        Header.Set("Error", E.Message);
        Header.Set("Result", "0");
        throw;
    }

As for the actual cause of the original error, that is something that will
have to be looked into more deeply.  Since Indy 10 is currently undergoing a
major code review right now, the issue may have already been addressed for
the next release.


Gambit
Technical Details
Message-ID: <46b2253a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <46ae4529$1@newsgroups.borland.com> <46af7382@newsgroups.borland.com> <3mtua39vadcc2de0p2ertm0fl224sevvu7@4ax.com> <46af7f59$1@newsgroups.borland.com> <46af83cc$1@newsgroups.borland.com> <46af86e7@newsgroups.borland.com> <46afa742$1@newsgroups.borland.com> <46afb0f1$1@newsgroups.borland.com> <46b10f2b$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,da4e10289ba23828
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <46ae4529$1@newsgroups.borland.com> <46af7382@newsgroups.borland.com> <3mtua39vadcc2de0p2ertm0fl224sevvu7@4ax.com> <46af7f59$1@newsgroups.borland.com> <46af83cc$1@newsgroups.borland.com> <46af86e7@newsgroups.borland.com> <46afa742$1@newsgroups.borland.com> <46afb0f1$1@newsgroups.borland.com> <46b10f2b$1@newsgroups.borland.com>
Subject: Re: Assertion Error while sending email
Date: Thu, 2 Aug 2007 11:40:21 -0700
Lines: 101
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.83.29.61
Message-ID: <46b2253a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1186080058 75.83.29.61 (2 Aug 2007 11:40:58 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail