[Twisted-Python] Getting error code

Itamar Shtull-Trauring itamar at itamarst.org
Thu May 13 14:27:59 EDT 2004

On Thu, 2004-05-13 at 14:18, Sorin C. wrote:

> Is there a way to extract the error code from a
> Failure instance? For example when
> clientConnectionFailed is called the 'value' field of
> the Failure instance is 'Connection was refused by
> other side: 10061: Unknown error.'. Can I get 10061
> somehow as I don't feel safe  parsing this string.

value.errno should do it. A better idea would be to go by exception
type, e.g. in this case you should be getting a
twisted.internet.error.ConnectionRefusedError or something instance as
the value object.

Itamar Shtull-Trauring    http://itamarst.org

More information about the Twisted-Python mailing list