summaryrefslogtreecommitdiffstats
path: root/polymatrix/utils/tooperatorexception.py
diff options
context:
space:
mode:
authorMichael Schneeberger <michael.schneeberger@fhnw.ch>2024-02-10 15:28:11 +0100
committerMichael Schneeberger <michael.schneeberger@fhnw.ch>2024-02-10 15:28:11 +0100
commita1ac1abd1488d018257b1788ecb18b1bddbb3cbe (patch)
tree9fea3b4e964bd98957939f19ce92128bb52703be /polymatrix/utils/tooperatorexception.py
parentdo not delete position when substracting monomials (diff)
downloadpolymatrix-a1ac1abd1488d018257b1788ecb18b1bddbb3cbe.tar.gz
polymatrix-a1ac1abd1488d018257b1788ecb18b1bddbb3cbe.zip
move init expr functions into a single file
Diffstat (limited to 'polymatrix/utils/tooperatorexception.py')
-rw-r--r--polymatrix/utils/tooperatorexception.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/polymatrix/utils/tooperatorexception.py b/polymatrix/utils/tooperatorexception.py
new file mode 100644
index 0000000..5f7db0f
--- /dev/null
+++ b/polymatrix/utils/tooperatorexception.py
@@ -0,0 +1,14 @@
+from polymatrix.utils.getstacklines import FrameSummary
+
+
+def to_operator_exception(
+ message: str,
+ stack: tuple[FrameSummary],
+) -> str:
+ exception_lines = [
+ message,
+ f' Assertion traceback (most recent call last):',
+ *(f' File "{stack_line.filename}", line {stack_line.lineno}\n {stack_line.line}' for stack_line in stack),
+ ]
+
+ return '\n'.join(exception_lines)