From 16654b5a4dbce16341adfba60388af756dd0e4ab Mon Sep 17 00:00:00 2001 From: Chris Burr Date: Thu, 28 Sep 2023 06:59:24 +0200 Subject: [PATCH] Improve error message on the client --- .../Service/ProxyManagerHandler.py | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/DIRAC/FrameworkSystem/Service/ProxyManagerHandler.py b/src/DIRAC/FrameworkSystem/Service/ProxyManagerHandler.py index 3ef55a96535..4b2177b87a5 100644 --- a/src/DIRAC/FrameworkSystem/Service/ProxyManagerHandler.py +++ b/src/DIRAC/FrameworkSystem/Service/ProxyManagerHandler.py @@ -428,16 +428,21 @@ def export_exchangeProxyForToken(self): group = credDict["group"] scopes = [f"vo:{vo}", f"group:{group}"] + [f"property:{prop}" for prop in dirac_properties] - r = requests.get( - f"{diracxUrl}/auth/legacy-exchange", - params={ - "preferred_username": credDict["username"], - "scope": " ".join(scopes), - }, - headers={"Authorization": f"Bearer {apiKey}"}, - ) + try: + r = requests.get( + f"{diracxUrl}/auth/legacy-exchange", + params={ + "preferred_username": credDict["username"], + "scope": " ".join(scopes), + }, + headers={"Authorization": f"Bearer {apiKey}"}, + ) + except requests.exceptions.RequestException as exc: + return S_ERROR(f"Failed to contact DiracX: {exc}") + else: + if not r.ok: + return S_ERROR(f"Failed to contact DiracX: {r.status_code} {r.text}") - r.raise_for_status() return S_OK(r.json())