Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add error handling to prevent crash #15

Merged
merged 5 commits into from Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Expand Up @@ -111,4 +111,5 @@ messages_control.disable = [
"missing-class-docstring",
"missing-function-docstring",
"missing-module-docstring",
"broad-except"
]
18 changes: 16 additions & 2 deletions src/uproot_browser/plot_view.py
Expand Up @@ -38,8 +38,22 @@ 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))
try:
canvas = make_plot(self.item, width, height)
rich_canvas = rich.console.Group(*self.decoder.decode(canvas))
except Exception:
rich_canvas = rich.console.Group(
rich.traceback.Traceback(
extra_lines=1,
max_frames=4, # Can't be less than 4 frames
)
)
amangoel185 marked this conversation as resolved.
Show resolved Hide resolved

if options.height is not None:
options.height -= 4
yield from rich_canvas.__rich_console__(console, options)
return

yield rich_canvas


Expand Down