Skip to content

Commit 36dcd20

Browse files
committed
fix (diracx): clearer error message
1 parent af7ab51 commit 36dcd20

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/DIRAC/Core/Security/DiracX.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ def DiracXClient() -> _DiracClient:
7474

7575
proxyLocation = getDefaultProxyLocation()
7676
diracxToken = diracxTokenFromPEM(proxyLocation)
77+
if not diracxToken:
78+
raise ValueError(f"No dirax token in the proxy file {proxyLocation}")
7779

7880
with NamedTemporaryFile(mode="wt") as token_file:
7981
token_file.write(json.dumps(diracxToken))

src/DIRAC/FrameworkSystem/scripts/dirac_diracx_whoami.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
def main():
1414
Script.parseCommandLine()
1515

16-
with DiracXClient() as api:
17-
user_info = api.auth.userinfo()
18-
print(json.dumps(user_info.as_dict(), indent=2))
16+
try:
17+
with DiracXClient() as api:
18+
user_info = api.auth.userinfo()
19+
print(json.dumps(user_info.as_dict(), indent=2))
20+
except Exception as e:
21+
print(f"Failed to access DiracX: {e}")
1922

2023

2124
if __name__ == "__main__":

0 commit comments

Comments
 (0)