diff --git a/pyproject.toml b/pyproject.toml index e6a43db..eb0aed5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,4 +111,5 @@ messages_control.disable = [ "missing-class-docstring", "missing-function-docstring", "missing-module-docstring", + "broad-except" ] diff --git a/src/uproot_browser/plot_view.py b/src/uproot_browser/plot_view.py index db71939..8471e46 100644 --- a/src/uproot_browser/plot_view.py +++ b/src/uproot_browser/plot_view.py @@ -38,9 +38,18 @@ def __rich_console__( ) -> rich.console.RenderResult: width = options.max_width or console.width height = options.height or console.height - canvas = make_plot(self.item, width, height) - rich_canvas = rich.console.Group(*self.decoder.decode(canvas)) - yield rich_canvas + try: + canvas = make_plot(self.item, width, height) + yield rich.console.Group(*self.decoder.decode(canvas)) + except Exception: + rich_canvas = rich.traceback.Traceback( + extra_lines=1, + max_frames=4, # Can't be less than 4 frames + ) + + if options.height is not None: + options.height -= 4 + yield from rich_canvas.__rich_console__(console, options) class PlotWidget(textual.widget.Widget): # type: ignore[misc]