improve handling for Connection errors
parent
36f7a0c9c9
commit
3dca417875
|
@ -54,13 +54,19 @@ class ContentTyper(object):
|
||||||
return r
|
return r
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
elif '[Errno 60]' in str(ce):
|
elif ('TimeoutError' in str(ce) or
|
||||||
return (408, '', '')
|
'ConnectionTimeout' in str(ce) or
|
||||||
# unexplained error
|
'[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)
|
logger.exception(ce)
|
||||||
return None
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# unexplained error
|
# unexplained error
|
||||||
|
logger.exception(type(e))
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue