Skip to content

Commit 568a874

Browse files
authored
Merge pull request #408 from RoseauTechnologies/error-message
ENH: Improve error message
2 parents 3ed3870 + af47e8e commit 568a874

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

roseau/load_flow/license.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import datetime as dt
22
import logging
33
import os
4+
import re
45

56
import certifi
67
from platformdirs import user_cache_dir
@@ -89,7 +90,10 @@ def activate_license(key: str | None = None) -> None:
8990
cy_activate_license(key=key, cacert_filepath=certifi.where(), cache_folderpath=user_cache_dir())
9091
_license = None
9192
except RuntimeError as e:
92-
msg = f"The license cannot be activated. The detailed error message is {e.args[0][2:]!r}."
93+
err_msg = e.args[0]
94+
if re.search(r"^[0-2] ", err_msg):
95+
err_msg = err_msg[2:]
96+
msg = f"The license cannot be activated. The detailed error message is {err_msg!r}."
9397
logger.error(msg)
9498
raise RoseauLoadFlowException(msg=msg, code=RoseauLoadFlowExceptionCode.LICENSE_ERROR) from e
9599

0 commit comments

Comments
 (0)