Put an exception handler around console.print

This is to handle any failures in the print method and defer exception handling to the Handler.handleErrors method.
This commit is contained in:
Tim Savage 2021-10-22 12:25:43 +11:00
parent 5876f5cacc
commit 137adbabf8
1 changed files with 4 additions and 1 deletions

View File

@ -150,7 +150,10 @@ class RichHandler(Handler):
log_renderable = self.render(
record=record, traceback=traceback, message_renderable=message_renderable
)
try:
self.console.print(log_renderable)
except Exception:
self.handleError(record)
def render_message(self, record: LogRecord, message: str) -> "ConsoleRenderable":
"""Render message text in to Text.