On 7/15/07, Alan Kennedy <jython-users@...> wrote:
> > The first time the client attempts to send data to the server (at this
> > point, the server has closed the socket), no error is raised (similar
> > behavior with Python2.5). But at the second time the client attempts
> > to send data to the server, Python2.5 raises an error, and the client
> > successfully catches it.
> > In Jython2.2 RC 2, however, a java.io.IOException occurs. So client
> > script can't do anything to stop it.
> Are you sure about that? Specifically, what code do you have put in
> place to catch that exception?
> If it is raising a java.io.IOException, then you would have to use the
> following code to catch it
> except java.io.IOException, jiox:
> print "There was a java IO exception"
> But I think your code is actually raising a socket.error, and the
> java.io.IOException is wrapped in that. So the following code will catch
> except socket.error, se:
> print "Socket exception is: %s" % se
> "Socket exception is: Unmapped java exception: java.io.IOException"
> Am I wrong?
> I need to put in another mapping for that exception.
If you look at the code that I included in the email, specifically the
one below, I do have a simple "except socket.error:" in place. When
sendtry() is first called, no error is raised (both in Jython and
Python). Second time sendtry() is called, Python raises the socket
error, Jython doesn't and it immediately gives me the "Exception in
thread Thread-2:... Traceback (most recent call last):" error.
def sendtry(self, s, n):
print "Client attempting to send data. Try no. %s" % n
print "Socket error at try no. %s" % n
print "Client closed from try no. %s" % n
In terms of Jython's reaction, probably there's a difference between:
except socket.error, error_message_here:
I do hope that others will also try the snippet that I have included
in first email just to verify this thing? I have pasted it on:
http://www.nomorepasting.com/getpaste.php?pasteid=1424 for everyone's
Thanks and best regards.