From 5bf722c7ae1eab214cc54db2d48b3d47b89ec3de Mon Sep 17 00:00:00 2001 From: Raphael Deem Date: Wed, 25 Oct 2017 21:58:31 -0700 Subject: [PATCH] remove bare exceptions --- sanic/app.py | 4 ++-- sanic/response.py | 2 +- sanic/server.py | 2 +- sanic/testing.py | 4 ++-- sanic/worker.py | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sanic/app.py b/sanic/app.py index 8f70b6e7..0f2141c2 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -574,7 +574,7 @@ class Sanic: try: response = await self._run_response_middleware(request, response) - except: + except BaseException: error_logger.exception( 'Exception occured in one of response middleware handlers' ) @@ -642,7 +642,7 @@ class Sanic: serve(**server_settings) else: serve_multiple(server_settings, workers) - except: + except BaseException: error_logger.exception( 'Experienced exception while trying to serve') raise diff --git a/sanic/response.py b/sanic/response.py index 86f50038..3873d90f 100644 --- a/sanic/response.py +++ b/sanic/response.py @@ -3,7 +3,7 @@ from os import path try: from ujson import dumps as json_dumps -except: +except BaseException: from json import dumps as json_dumps from aiofiles import open as open_async diff --git a/sanic/server.py b/sanic/server.py index 049440dd..a475fd98 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -588,7 +588,7 @@ def serve(host, port, request_handler, error_handler, before_start=None, try: http_server = loop.run_until_complete(server_coroutine) - except: + except BaseException: logger.exception("Unable to start server") return diff --git a/sanic/testing.py b/sanic/testing.py index 5d233d7b..ef54537b 100644 --- a/sanic/testing.py +++ b/sanic/testing.py @@ -76,14 +76,14 @@ class SanicTestClient: try: request, response = results return request, response - except: + except BaseException: raise ValueError( "Request and response object expected, got ({})".format( results)) else: try: return results[-1] - except: + except BaseException: raise ValueError( "Request object expected, got ({})".format(results)) diff --git a/sanic/worker.py b/sanic/worker.py index a102fb72..79c0a17d 100644 --- a/sanic/worker.py +++ b/sanic/worker.py @@ -74,13 +74,13 @@ class GunicornWorker(base.Worker): trigger_events(self._server_settings.get('before_stop', []), self.loop) self.loop.run_until_complete(self.close()) - except: + except BaseException: traceback.print_exc() finally: try: trigger_events(self._server_settings.get('after_stop', []), self.loop) - except: + except BaseException: traceback.print_exc() finally: self.loop.close()