MCPcopy
hub / github.com/shadowsocks/shadowsocks / errno_from_exception

Function errno_from_exception

shadowsocks/eventloop.py:230–245  ·  view source on GitHub ↗

Provides the errno from an Exception object. There are cases that the errno attribute was not set so we pull the errno out of the args but if someone instatiates an Exception without any args you will get a tuple error. So this function abstracts all that behavior to give you a safe

(e)

Source from the content-addressed store, hash-verified

228
229# from tornado
230def errno_from_exception(e):
231 """Provides the errno from an Exception object.
232
233 There are cases that the errno attribute was not set so we pull
234 the errno out of the args but if someone instatiates an Exception
235 without any args you will get a tuple error. So this function
236 abstracts all that behavior to give you a safe way to get the
237 errno.
238 """
239
240 if hasattr(e, 'errno'):
241 return e.errno
242 elif e.args:
243 return e.args[0]
244 else:
245 return None
246
247
248# from tornado

Callers 1

runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected