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

fix: Better render error handling #242

Merged
merged 3 commits into from
Jan 31, 2024

Conversation

jnumainville
Copy link
Collaborator

@jnumainville jnumainville commented Jan 30, 2024

Fixes #227

Testing with the examples from the issue logged errors, for example:

import deephaven.ui as ui

@ui.component
def hi():
    something, set_something = ui.use_state(0)
    return "Hello, " + something

h = hi()
Error rendering __main__.hi
Traceback (most recent call last):
  File "/Users/josephnumainville/Documents/deephaven-core/.venv/lib/python3.8/site-packages/deephaven/ui/object_types/ElementMessageStream.py", line 153, in _render
    node = self._renderer.render(self._element)
  File "/Users/josephnumainville/Documents/deephaven-core/.venv/lib/python3.8/site-packages/deephaven/ui/renderer/Renderer.py", line 111, in render
    return _render_element(element, self._context)
  File "/Users/josephnumainville/Documents/deephaven-core/.venv/lib/python3.8/site-packages/deephaven/ui/renderer/Renderer.py", line 84, in _render_element
    props = element.render(context)
  File "/Users/josephnumainville/Documents/deephaven-core/.venv/lib/python3.8/site-packages/deephaven/ui/elements/FunctionElement.py", line 37, in render
    children = self._render()
  File "/Users/josephnumainville/Documents/deephaven-core/.venv/lib/python3.8/site-packages/deephaven/ui/components/make_component.py", line 23, in <lambda>
    return FunctionElement(component_type, lambda: func(*args, **kwargs))
  File "<string>", line 6, in hi
TypeError: can only concatenate str (not "int") to str

another:

from deephaven import ui

@ui.component
def foo():
    return ui.bad_component()


f = foo()
Error rendering __main__.foo
Traceback (most recent call last):
  File "/Users/josephnumainville/Documents/deephaven-core/.venv/lib/python3.8/site-packages/deephaven/ui/object_types/ElementMessageStream.py", line 153, in _render
    node = self._renderer.render(self._element)
  File "/Users/josephnumainville/Documents/deephaven-core/.venv/lib/python3.8/site-packages/deephaven/ui/renderer/Renderer.py", line 111, in render
    return _render_element(element, self._context)
  File "/Users/josephnumainville/Documents/deephaven-core/.venv/lib/python3.8/site-packages/deephaven/ui/renderer/Renderer.py", line 84, in _render_element
    props = element.render(context)
  File "/Users/josephnumainville/Documents/deephaven-core/.venv/lib/python3.8/site-packages/deephaven/ui/elements/FunctionElement.py", line 37, in render
    children = self._render()
  File "/Users/josephnumainville/Documents/deephaven-core/.venv/lib/python3.8/site-packages/deephaven/ui/components/make_component.py", line 23, in <lambda>
    return FunctionElement(component_type, lambda: func(*args, **kwargs))
  File "<string>", line 5, in foo
AttributeError: module 'deephaven.ui' has no attribute 'bad_component'

@jnumainville jnumainville requested a review from mofojed January 30, 2024 20:44
@jnumainville jnumainville changed the title bug: Better render error handling fix: Better render error handling Jan 30, 2024
Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks

@jnumainville jnumainville merged commit c312d43 into deephaven:main Jan 31, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Frustrating deephaven.ui error handling
2 participants