Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to raise a socket "104 connection reset by peer error"

15 views
Skip to first unread message

loial

unread,
May 21, 2013, 11:26:13 AM5/21/13
to
For testing purposes I want my code to raise a socket "connection reset by peer" error, so that I can test how I handle it, but I am not sure how to raise the error.

Any advice appreciated


Andrew Berg

unread,
May 21, 2013, 11:49:31 AM5/21/13
to comp.lang.python
On 2013.05.21 10:26, loial wrote:
> For testing purposes I want my code to raise a socket "connection reset by peer" error, so that I can test how I handle it, but I am not sure how to raise the error.
Arbitrary exceptions can be raised with the raise keyword. In Python 3.3, that exact error got its own builtin exception:
http://docs.python.org/3.3/tutorial/errors.html#raising-exceptions
http://docs.python.org/3.3/library/exceptions.html#ConnectionResetError

In earlier versions of Python, you will have to raise OSError and set its errno attribute.

--
CPython 3.3.2 | Windows NT 6.2.9200 / FreeBSD 9.1
0 new messages