From b3e11e1d2f172ccacab0ad3bfab1c655fd7a9c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Tue, 12 Oct 2021 01:06:25 +0200 Subject: [PATCH] better error messages --- canaille/__init__.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/canaille/__init__.py b/canaille/__init__.py index dd853883..b4e094ca 100644 --- a/canaille/__init__.py +++ b/canaille/__init__.py @@ -41,7 +41,10 @@ def create_app(config=None): dir_path = os.path.dirname(os.path.realpath(__file__)) app.config.from_mapping( - {"SESSION_COOKIE_NAME": "canaille", "OAUTH2_REFRESH_TOKEN_GENERATOR": True,} + { + "SESSION_COOKIE_NAME": "canaille", + "OAUTH2_REFRESH_TOKEN_GENERATOR": True, + } ) if config: app.config.from_mapping(config) @@ -59,10 +62,14 @@ def create_app(config=None): setup_dev_keypair(app) - if not os.path.exists(app.config["JWT"]["PUBLIC_KEY"]) or not os.path.exists( - app.config["JWT"]["PRIVATE_KEY"] - ): - raise Exception("Invalid keypair") + if not os.path.exists(app.config["JWT"]["PUBLIC_KEY"]): + raise Exception(f'Public key does not exist {app.config["JWT"]["PUBLIC_KEY"]}') + + if not os.path.exists(app.config["JWT"]["PRIVATE_KEY"]): + raise Exception( + f'Private key does not exist {app.config["JWT"]["PRIVATE_KEY"]}' + ) + setup_app(app) return app