MCPcopy
hub / github.com/tornadoweb/tornado / errno_from_exception

Function errno_from_exception

tornado/util.py:161–176  ·  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

159
160
161def errno_from_exception(e: BaseException) -> Optional[int]:
162 """Provides the errno from an Exception object.
163
164 There are cases that the errno attribute was not set so we pull
165 the errno out of the args but if someone instantiates an Exception
166 without any args you will get a tuple error. So this function
167 abstracts all that behavior to give you a safe way to get the
168 errno.
169 """
170
171 if hasattr(e, "errno"):
172 return e.errno # type: ignore
173 elif e.args:
174 return e.args[0]
175 else:
176 return None
177
178
179_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