Quiet EPIPE tracebacks

Co-Authored-By: Alistair Coles <alistairncoles@gmail.com>
Change-Id: Ibf6cce2447921b58f5a0dff630ea5a0c6284119c
This commit is contained in:
Tim Burke 2021-06-17 16:41:20 -07:00
parent bbcd8e90f2
commit 0d05a8ff38
2 changed files with 14 additions and 0 deletions

View File

@ -2242,6 +2242,8 @@ class LogAdapter(logging.LoggerAdapter, object):
emsg = _('Network unreachable')
elif exc.errno == errno.ETIMEDOUT:
emsg = _('Connection timeout')
elif exc.errno == errno.EPIPE:
emsg = _('Broken pipe')
else:
call = self._exception
elif isinstance(exc, http_client.BadStatusLine):

View File

@ -1925,6 +1925,18 @@ class TestUtils(unittest.TestCase):
self.assertNotIn('Traceback', log_msg)
self.assertNotIn('my error message', log_msg)
self.assertIn('Connection timeout', log_msg)
log_exception(socket.error(errno.ENETUNREACH, 'my error message'))
log_msg = strip_value(sio)
self.assertNotIn('Traceback', log_msg)
self.assertNotIn('my error message', log_msg)
self.assertIn('Network unreachable', log_msg)
log_exception(socket.error(errno.EPIPE, 'my error message'))
log_msg = strip_value(sio)
self.assertNotIn('Traceback', log_msg)
self.assertNotIn('my error message', log_msg)
self.assertIn('Broken pipe', log_msg)
# unfiltered
log_exception(socket.error(0, 'my error message'))
log_msg = strip_value(sio)