Skip to content

Commit

Permalink
Make error messages a bit more informative in terms of who is causing…
Browse files Browse the repository at this point in the history
… the error
  • Loading branch information
cpsievert committed Jan 30, 2025
1 parent 7caa2e4 commit 0afcb87
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion shiny/reactive/_reactives.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ async def _run(self) -> None:
from .._app import SANITIZE_ERROR_MSG
from ..ui import notification_show

msg = "Error in Effect: " + str(e)
msg = str(e)
if e.sanitize:
msg = SANITIZE_ERROR_MSG
notification_show(msg, type="error", duration=5000)
Expand Down
3 changes: 2 additions & 1 deletion shiny/ui/_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ async def _raise_exception(
else:
await self._remove_loading_message()
sanitize = self.on_error == "sanitize"
raise NotifyException(str(e), sanitize=sanitize) from e
msg = f"Error in Chat('{self.id}'): {str(e)}"
raise NotifyException(msg, sanitize=sanitize) from e

@overload
def messages(
Expand Down
3 changes: 2 additions & 1 deletion shiny/ui/_markdown_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ async def _raise_exception(self, e: BaseException):
raise e
else:
sanitize = self.on_error == "sanitize"
raise NotifyException(str(e), sanitize=sanitize) from e
msg = f"Error in MarkdownStream('{self.id}'): {str(e)}"
raise NotifyException(msg, sanitize=sanitize) from e

def _send_custom_message(self, msg: Union[ContentMessage, isStreamingMessage]):
if self._session.is_stub_session():
Expand Down

0 comments on commit 0afcb87

Please sign in to comment.