From d67445057a3043f15f85f6f1a5c66281471aae71 Mon Sep 17 00:00:00 2001 From: David Evans Date: Thu, 21 Sep 2023 08:57:10 +0100 Subject: [PATCH] Raise an explicit error for TRUD login failure This should make it easier to identify the issue in future. --- openprescribing/dmd/management/commands/fetch_dmd.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openprescribing/dmd/management/commands/fetch_dmd.py b/openprescribing/dmd/management/commands/fetch_dmd.py index c5bf4ed6f3..98284d81ae 100644 --- a/openprescribing/dmd/management/commands/fetch_dmd.py +++ b/openprescribing/dmd/management/commands/fetch_dmd.py @@ -32,6 +32,10 @@ def handle(self, *args, **kwargs): "commit": "LOG+IN", } rsp = session.post(login_url, params) + if "The email address or password is invalid" in rsp.text: + raise RuntimeError( + f"TRUD login failure for username: {settings.TRUD_USERNAME!r}" + ) index_url = ( base_url