From a1ac1abd1488d018257b1788ecb18b1bddbb3cbe Mon Sep 17 00:00:00 2001 From: Michael Schneeberger Date: Sat, 10 Feb 2024 15:28:11 +0100 Subject: move init expr functions into a single file --- polymatrix/utils/tooperatorexception.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 polymatrix/utils/tooperatorexception.py (limited to 'polymatrix/utils/tooperatorexception.py') 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) -- cgit v1.2.1