remove bare exceptions

This commit is contained in:
Raphael Deem 2017-10-25 21:58:31 -07:00
parent c2191153cf
commit 5bf722c7ae
5 changed files with 8 additions and 8 deletions

View File

@ -574,7 +574,7 @@ class Sanic:
try: try:
response = await self._run_response_middleware(request, response = await self._run_response_middleware(request,
response) response)
except: except BaseException:
error_logger.exception( error_logger.exception(
'Exception occured in one of response middleware handlers' 'Exception occured in one of response middleware handlers'
) )
@ -642,7 +642,7 @@ class Sanic:
serve(**server_settings) serve(**server_settings)
else: else:
serve_multiple(server_settings, workers) serve_multiple(server_settings, workers)
except: except BaseException:
error_logger.exception( error_logger.exception(
'Experienced exception while trying to serve') 'Experienced exception while trying to serve')
raise raise

View File

@ -3,7 +3,7 @@ from os import path
try: try:
from ujson import dumps as json_dumps from ujson import dumps as json_dumps
except: except BaseException:
from json import dumps as json_dumps from json import dumps as json_dumps
from aiofiles import open as open_async from aiofiles import open as open_async

View File

@ -588,7 +588,7 @@ def serve(host, port, request_handler, error_handler, before_start=None,
try: try:
http_server = loop.run_until_complete(server_coroutine) http_server = loop.run_until_complete(server_coroutine)
except: except BaseException:
logger.exception("Unable to start server") logger.exception("Unable to start server")
return return

View File

@ -76,14 +76,14 @@ class SanicTestClient:
try: try:
request, response = results request, response = results
return request, response return request, response
except: except BaseException:
raise ValueError( raise ValueError(
"Request and response object expected, got ({})".format( "Request and response object expected, got ({})".format(
results)) results))
else: else:
try: try:
return results[-1] return results[-1]
except: except BaseException:
raise ValueError( raise ValueError(
"Request object expected, got ({})".format(results)) "Request object expected, got ({})".format(results))

View File

@ -74,13 +74,13 @@ class GunicornWorker(base.Worker):
trigger_events(self._server_settings.get('before_stop', []), trigger_events(self._server_settings.get('before_stop', []),
self.loop) self.loop)
self.loop.run_until_complete(self.close()) self.loop.run_until_complete(self.close())
except: except BaseException:
traceback.print_exc() traceback.print_exc()
finally: finally:
try: try:
trigger_events(self._server_settings.get('after_stop', []), trigger_events(self._server_settings.get('after_stop', []),
self.loop) self.loop)
except: except BaseException:
traceback.print_exc() traceback.print_exc()
finally: finally:
self.loop.close() self.loop.close()