improve handling for Connection errors

main
eric 2024-03-13 17:21:28 -04:00
parent 36f7a0c9c9
commit 3dca417875
1 changed files with 10 additions and 4 deletions

View File

@ -54,13 +54,19 @@ class ContentTyper(object):
return r
except Exception as e:
pass
elif '[Errno 60]' in str(ce):
return (408, '', '')
# unexplained error
elif ('TimeoutError' in str(ce) or
'ConnectionTimeout' in str(ce) or
'[Errno 60]' in str(ce)):
# server didn't respond in a reasonable time
return (524, '', '')
elif '[Errno 111]' in str(ce) or 'Max retries' in str(ce):
# I'm a teapot, I hate you
return (418, '', '')
# unexplained connection error
logger.exception(ce)
return None
except Exception as e:
# unexplained error
logger.exception(type(e))
logger.exception(e)
return None