Skip to content

Commit 2bec9bd

Browse files
committed
Merge pull request #212 in LCL/wolframclientforpython from bugfix/380845-exception-dispatch to master
* commit '9eabf923d2fea0a721e538557bc2eda82005544f': adding hooks for databases adding exception_class
2 parents cb681ba + 9eabf92 commit 2bec9bd

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

wolframclient/language/decorators.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
def safe_wl_execute(
19-
function, args=(), opts={}, export_opts={}, exception_class=WolframLanguageException
19+
function, args=(), opts={}, export_opts={}, exception_class=None
2020
):
2121

2222
__traceback_hidden_variables__ = True
@@ -37,7 +37,7 @@ def safe_wl_execute(
3737
except Exception:
3838
pass
3939

40-
if exception_class is WolframLanguageException:
40+
if not exception_class or exception_class is WolframLanguageException:
4141
return export(
4242
WolframLanguageException(export_exception, exec_info=sys.exc_info()),
4343
**export_opts
@@ -84,12 +84,16 @@ def safe_wl_execute(
8484
]
8585

8686

87-
def to_wl(**export_opts):
87+
def to_wl(exception_class=None, **export_opts):
8888
def outer(function):
8989
@wraps(function)
9090
def inner(*args, **opts):
9191
return safe_wl_execute(
92-
function=function, args=args, opts=opts, export_opts=export_opts
92+
function=function,
93+
args=args,
94+
opts=opts,
95+
export_opts=export_opts,
96+
exception_class=exception_class,
9397
)
9498

9599
return inner

wolframclient/utils/externalevaluate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,12 @@ def start_zmq_loop(
188188
redirect_stdout=True,
189189
export_kwargs=EXPORT_KWARGS,
190190
evaluate_message=evaluate_message,
191+
exception_class=None,
191192
consumer=None,
192193
**opts
193194
):
194195

195-
handler = to_wl(**export_kwargs)(handle_message)
196+
handler = to_wl(exception_class=exception_class, **export_kwargs)(handle_message)
196197

197198
socket = start_zmq_instance(**opts)
198199

0 commit comments

Comments
 (0)