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

Elaborate on callback exception summary #6046

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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