[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Re: Exception in the socket code

From: Holger Hans Peter Freyther
Subject: Re: [Help-smalltalk] Re: Exception in the socket code
Date: Sat, 26 Mar 2011 11:23:22 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.9

On 03/26/2011 11:11 AM, Paolo Bonzini wrote:

> Yes, your original idea of returning 0 now is correct.  checkError will return
> 0 for you:

What about the following?

> +                    ifFail: [self checkError].

                       ifFail: [SystemExceptions.EndOfStream signalOn: self]

E.g. if I use socket nextLine I will now get a '' as the result that I would
need to handle specially. I am talking to a server right now and I know that
it needs to send 'username: ' right now and my code is doing something like:

tmp := socket nextPart. "like nextLine but also checks for $:"
tmp = 'username' ifFalse: [^self error: '']
] on: SystemExceptions.EndOfStream do: [].

With the proposed change to add ifFail: [self checkError] I will now either
need to do:

] on: SystemExceptions.EndOfStream do: []
  on: Error do: [].


tmp := socket nextPart.
(tmp isEmpty and: [socket atEnd]) ifTrue: [graceful exit]

or move the graceful part into nextLine and nextPart, and would need to
differentiate if nextLine has actually read anything at all.

what do you think?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]