Skip to content

Commit e5c5e70

Browse files
committed
added stub function for run_editor_on_exception
1 parent 584f6da commit e5c5e70

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

doc/source/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ Editor
827827
view
828828
edit
829829
compare
830+
run_editor_on_exception
830831

831832
Random
832833
======

larray/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
from larray.util.options import get_options, set_options
4040

41-
from larray.viewer import view, edit, compare
41+
from larray.viewer import view, edit, compare, run_editor_on_exception
4242

4343
from larray.extra.ipfp import ipfp
4444

@@ -81,7 +81,7 @@
8181
# utils
8282
'get_options', 'set_options',
8383
# viewer
84-
'view', 'edit', 'compare',
84+
'view', 'edit', 'compare', 'run_editor_on_exception',
8585
# ipfp
8686
'ipfp',
8787
# example

larray/viewer/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,27 @@ def compare(*args, **kwargs):
105105
compare(*args, depth=depth + 1, **kwargs)
106106
except ImportError:
107107
raise Exception('compare() is not available because the larray_editor package is not installed')
108+
109+
110+
def run_editor_on_exception(root_path=None, usercode_traceback=True):
111+
r"""
112+
Runs the editor when an unhandled exception (a fatal error) happens.
113+
114+
Parameters
115+
----------
116+
root_path : str, optional
117+
Defaults to None (the directory of the main script).
118+
usercode_traceback : bool, optional
119+
Whether or not to show only the part of the traceback (error log) which corresponds to the user code.
120+
Otherwise, it will show the complete traceback, including code inside libraries. Defaults to True.
121+
122+
Notes
123+
-----
124+
sets sys.excepthook
125+
"""
126+
try:
127+
from larray_editor import run_editor_on_exception
128+
129+
run_editor_on_exception(root_path=root_path, usercode_traceback=usercode_traceback)
130+
except ImportError:
131+
raise Exception('run_editor_on_exception() is not available because the larray_editor package is not installed')

0 commit comments

Comments
 (0)