Skip to content

Exceptions raised in DynamicMap callable not caught by exception handler #8670

Description

@TheoMathurin

ALL software version info

Software Version Info
panel 1.9.3
holoviews 1.23.1
bokeh 3.9.1

Description of expected behavior and the observed behavior

I would have thought errors occurring in a DynamicMap callable would be handled by the exception handler. Instead, the handler function is not executed.

Complete, minimal, self-contained example code that reproduces the issue

In the following, a DynamicMap callable raises an exception for a particular value of the input. This exception is not handled. As a control I also include a button associated with a callback triggering an exception which is adequately handled.

import holoviews as hv
import numpy as np
import panel as pn


def exception_handler(e):
    """Handle and log unexpected exception and notifies user"""
    print(f"Unexpected Exception: {e}")
    pn.state.notifications.error(f"Unexpected Exception: {e}")


pn.extension(exception_handler=exception_handler, notifications=True)
pn.state.notifications.position = "top-left"


def raise_error(_):
    raise ValueError("Error raised")


def get_plot(value):
    if value == 4:
        raise ValueError("Error in plot")
    return hv.Points(data).opts(size=value)


data = np.random.rand(10, 2)
slider = pn.widgets.IntSlider(start=1, end=5, value=1)
dmap = hv.DynamicMap(pn.bind(get_plot, value=slider))
button = pn.widgets.Button(label="Button", on_click=raise_error)


pn.Column(button, dmap, slider).servable()

Stack traceback and/or browser JavaScript console output

2026-07-13 14:31:20,177 Starting Bokeh server version 3.9.1 (running on Tornado 6.5.7)
2026-07-13 14:31:20,177 User authentication hooks NOT provided (default user enabled)
2026-07-13 14:31:20,179 Bokeh app running at: http://localhost:5006/toast
2026-07-13 14:31:20,179 Starting Bokeh server with process id: 46581
2026-07-13 14:31:22,679 WebSocket connection opened
2026-07-13 14:31:22,680 ServerConnection created
Unexpected Exception: Error raised
WARNING:param.wrapped_sync: Callable raised "ValueError('Error in plot')".
Invoked as wrapped_sync(value=4)
2026-07-13 14:31:36,271 Callable raised "ValueError('Error in plot')".
Invoked as wrapped_sync(value=4)
Traceback (most recent call last):
  File "/home/user/.cache/uv/archive-v0/cSuNtOvSrdXgSCur/lib/python3.12/site-packages/holoviews/plotting/util.py", line 319, in get_plot_frame
    return map_obj[key]
           ~~~~~~~^^^^^
  File "/home/user/.cache/uv/archive-v0/cSuNtOvSrdXgSCur/lib/python3.12/site-packages/holoviews/core/spaces.py", line 1368, in __getitem__
    val = self._execute_callback(*tuple_key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.cache/uv/archive-v0/cSuNtOvSrdXgSCur/lib/python3.12/site-packages/holoviews/core/spaces.py", line 1118, in _execute_callback
    retval = self.callback(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.cache/uv/archive-v0/cSuNtOvSrdXgSCur/lib/python3.12/site-packages/holoviews/core/spaces.py", line 675, in __call__
    ret = self.callable(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.cache/uv/archive-v0/cSuNtOvSrdXgSCur/lib/python3.12/site-packages/param/depends.py", line 125, in _depends_sync
    return func(*args, **kw)
           ^^^^^^^^^^^^^^^^^
  File "/home/user/.cache/uv/archive-v0/cSuNtOvSrdXgSCur/lib/python3.12/site-packages/param/reactive.py", line 1353, in wrapped_sync
    return eval_fn()(*combined_args, **combined_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/workspace/project/test.py", line 22, in get_plot
    raise ValueError("Error in plot")
ValueError: Error in plot

Screenshots or screencasts of the bug in action

Capture.video.du.2026-07-13.14-31-27.webm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions