MCPcopy Create free account
hub / github.com/EasyIME/PIME / errno_from_exception

Function errno_from_exception

python/python3/tornado/util.py:178–193  ·  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 instantiates an Exception without any args you will get a tuple error. So this function abstracts all that behavior to give you a saf

(e: BaseException)

Source from the content-addressed store, hash-verified

176
177
178def errno_from_exception(e: BaseException) -> Optional[int]:
179 """Provides the errno from an Exception object.
180
181 There are cases that the errno attribute was not set so we pull
182 the errno out of the args but if someone instantiates an Exception
183 without any args you will get a tuple error. So this function
184 abstracts all that behavior to give you a safe way to get the
185 errno.
186 """
187
188 if hasattr(e, "errno"):
189 return e.errno # type: ignore
190 elif e.args:
191 return e.args[0]
192 else:
193 return None
194
195
196_alphanum = frozenset("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")

Callers 6

bind_socketsFunction · 0.90
bind_unix_socketFunction · 0.90
_is_connresetMethod · 0.90
_handle_connectMethod · 0.90
read_from_fdMethod · 0.90
_handle_connectionMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected