Hi!

I just wonder - why we have to use exceptions and exception handling so
often? I mean, why exceptions, not function results? For example:

procedure TNntpCli.List(DestStream : TStream);
begin
    if FState <> nntpReady then
          raise NntpException.Create('Not ready for LIST');
    FDataStream      := DestStream;

    FRequestType     := nntpList;
    FRequest         := 'LIST NEWSGROUPS';
    FNext            := GetArticleNext;
    StateChange(nntpWaitingResponse);
    SendRequest;
end;

Why not change it to

function TNntpCli.List(DestStream : TStream): boolean
begin
    if FState <> nntpReady then
          result:=false
    else
          begin;
          FDataStream      := DestStream;

          FRequestType     := nntpList;
          FRequest         := 'LIST NEWSGROUPS';
          FNext            := GetArticleNext;
          StateChange(nntpWaitingResponse);
          SendRequest;
          result:=true;
          end
end;

Currently, when exception is raised, sometimes I don't know if the exception
was raised in TWSocket, or TNntpCli (and I know that I could find that
out by checking exception class, but sometimes exception is raised not
because broken program logic, but because - for example - broken connection)
and I'm forced to use procedure-global exception handlers, or else I'll
end with a hell-lot of small exception handlers that would give me a bit
more info about what went wrong, but also complicate, enlarge and slow down
RequestDone procedures (which have to handle >10000 - yes, over ten thousand
- RequestDones per connection).

Personally... I hate exceptions...

-- 
Piotr "Hellrayzer" Dalek
Author of ICS-Based Hellcore Mailer - an Outlook Express killer
http://www.hcm.prv.pl
[EMAIL PROTECTED]

----------------------------------------------------------------------
Startuj z INTERIA.PL! >>> http://link.interia.pl/f186c 


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to