Move TimoutError check lower down in exception list

When called as a one-liner, the "else None" causes the following error:

TypeError: catching classes that do not inherit from BaseException is not allowed
This commit is contained in:
rallytime 2017-11-21 10:21:47 -05:00
parent d26d9ff5e4
commit 628f015c1b
No known key found for this signature in database
GPG Key ID: E8F1A4B90D0DEA19

View File

@ -761,12 +761,18 @@ def hypermedia_handler(*args, **kwargs):
except (salt.exceptions.SaltDaemonNotRunning,
salt.exceptions.SaltReqTimeoutError) as exc:
raise cherrypy.HTTPError(503, exc.strerror)
except (cherrypy.TimeoutError if hasattr(cherrypy, 'TimeoutError') else None,
salt.exceptions.SaltClientTimeout):
except salt.exceptions.SaltClientTimeout:
raise cherrypy.HTTPError(504)
except cherrypy.CherryPyException:
raise
except Exception as exc:
# The TimeoutError exception class was removed in CherryPy in 12.0.0, but
# Still check existence of TimeoutError and handle in CherryPy < 12.
# The check was moved down from the SaltClientTimeout error line because
# A one-line if statement throws a BaseException inheritance TypeError.
if hasattr(cherrypy, 'TimeoutError') and isinstance(exc, cherrypy.TimeoutError):
raise cherrypy.HTTPError(504)
import traceback
logger.debug("Error while processing request for: %s",