Skip to content

Commit a0cfe93

Browse files
authored
Merge pull request #93 from AzureAD/raise-without-log
Raise without log polluting the console
2 parents e889c44 + 208e0fc commit a0cfe93

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

msal_extensions/libsecret.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,29 @@
1313
pip install wheel
1414
PYGOBJECT_WITHOUT_PYCAIRO=1 pip install --no-build-isolation pygobject
1515
"""
16-
import logging
17-
18-
logger = logging.getLogger(__name__)
1916

2017
try:
2118
import gi # https://github.com/AzureAD/microsoft-authentication-extensions-for-python/wiki/Encryption-on-Linux # pylint: disable=line-too-long
2219
except ImportError:
23-
logger.exception(
24-
"""Runtime dependency of PyGObject is missing.
20+
raise ImportError("""Unable to import module 'gi'
21+
Runtime dependency of PyGObject is missing.
2522
Depends on your Linux distro, you could install it system-wide by something like:
2623
sudo apt install python3-gi python3-gi-cairo gir1.2-secret-1
2724
If necessary, please refer to PyGObject's doc:
2825
https://pygobject.readthedocs.io/en/latest/getting_started.html
29-
""")
30-
raise
26+
""") # Message via exception rather than log
3127

3228
try:
3329
# pylint: disable=no-name-in-module
3430
gi.require_version("Secret", "1") # Would require a package gir1.2-secret-1
3531
# pylint: disable=wrong-import-position
3632
from gi.repository import Secret # Would require a package gir1.2-secret-1
37-
except (ValueError, ImportError):
38-
logger.exception(
33+
except (ValueError, ImportError) as ex:
34+
raise type(ex)(
3935
"""Require a package "gir1.2-secret-1" which could be installed by:
4036
sudo apt install gir1.2-secret-1
41-
""")
42-
raise
37+
""") # Message via exception rather than log
38+
4339

4440
class LibSecretAgent(object):
4541
"""A loader/saver built on top of low-level libsecret"""
@@ -134,7 +130,5 @@ def trial_run():
134130
you may need to install gnome-keyring package.
135131
* Headless mode (such as in an ssh session) is not supported.
136132
"""
137-
logger.exception(message) # This log contains trace stack for debugging
138-
logger.warning(message) # This is visible by default
139-
raise
133+
raise RuntimeError(message) # Message via exception rather than log
140134

0 commit comments

Comments
 (0)