def handle_stream_closed_error(self, error, event):
if error.real_error:
err_num = abs(error.real_error[0])
try:
errorcode = errno.errorcode[err_num]
except KeyError:
errorcode = "undefined(code={0})".format(err_num)
logger.debug("connect to {0}:{1} with error code {2}".format(
event.addr, event.port, errorcode))
# NOTE: if we submit an incorrect address type,
# the error code will be:
# - ENOEXEC in macos.
# - EBADF in linux.
if err_num in (errno.ENOEXEC, errno.EBADF):
reason = "ADDRESS_TYPE_NOT_SUPPORTED"
elif err_num == errno.ETIMEDOUT:
reason = "NETWORK_UNREACHABLE"
else:
logger.error("unhandled error code {0} received".format(errorcode))
reason = "GENRAL_FAILURE"
yield self.send_event_to_src_conn(Response(
RESP_STATUS[reason],
event.atyp, event.addr, event.port), raise_exception=False)
raise DestNotConnectedError((event.addr, event.port))
else: # pragma: no cover
# TODO: StreamClosedError without real_error?
# need check that tornado would occur this situation?
raise
评论列表
文章目录