Skip to content

Commit

Permalink
Elaborate on callback exception summary (#6046)
Browse files Browse the repository at this point in the history
* Add elaborate on callback exception summary

* Fix test
  • Loading branch information
ahuang11 authored Dec 15, 2023
1 parent 3448cdd commit b9b431b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion panel/chat/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,11 @@ async def _prepare_response(self, _) -> None:
except Exception as e:
send_kwargs = dict(user="Exception", respond=False)
if self.callback_exception == "summary":
self.send(str(e), **send_kwargs)
self.send(
f"Encountered `{e!r}`. "
f"Set `callback_exception='verbose'` to see the full traceback.",
**send_kwargs
)
elif self.callback_exception == "verbose":
self.send(f"```python\n{traceback.format_exc()}\n```", **send_kwargs)
elif self.callback_exception == "ignore":
Expand Down
2 changes: 1 addition & 1 deletion panel/tests/chat/test_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def callback(msg, user, instance):
chat_feed.callback = callback
chat_feed.callback_exception = "summary"
chat_feed.send("Message", respond=True)
assert chat_feed.objects[-1].object == "division by zero"
assert "division by zero" in chat_feed.objects[-1].object
assert chat_feed.objects[-1].user == "Exception"

def test_callback_exception_traceback(self, chat_feed):
Expand Down

0 comments on commit b9b431b

Please sign in to comment.