aboutsummaryrefslogtreecommitdiffstats
path: root/mpm
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2023-06-09 11:10:34 +0200
committerAki Tomita <121511582+atomita-ni@users.noreply.github.com>2023-06-09 13:40:38 -0500
commit1415cc1ebb6e36112828210bb307ba682e5f81d9 (patch)
treee964be1162c79ac5121030b191a22226310ab1b6 /mpm
parentfpga: lib: Fix Vivado warnings (diff)
downloaduhd-1415cc1ebb6e36112828210bb307ba682e5f81d9.tar.xz
uhd-1415cc1ebb6e36112828210bb307ba682e5f81d9.zip
mpm: Add LogRuntimeError class
This inherits RuntimeError and saves from logging and throwing in separate steps. Instead of ```python log.error("Error X occured!") raise RuntimeError("Error X occured!") ``` do ```python raise LogRuntimeError(log, "Error X occured!") ```
Diffstat (limited to 'mpm')
-rw-r--r--mpm/python/usrp_mpm/mpmutils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/mpm/python/usrp_mpm/mpmutils.py b/mpm/python/usrp_mpm/mpmutils.py
index 861f8ac49..1f7bd7107 100644
--- a/mpm/python/usrp_mpm/mpmutils.py
+++ b/mpm/python/usrp_mpm/mpmutils.py
@@ -317,3 +317,13 @@ class LogWrapper:
"""
return getattr(self._wc, k)
# pylint: enable=too-few-public-methods
+
+
+class LogRuntimeError(RuntimeError):
+ """
+ Custom version of RuntimeError that also prints the exception message to
+ a logger.
+ """
+ def __init__(self, log, message):
+ log.error(message)
+ super.__init__(message)