Skip to content
Discussion options

You must be logged in to vote

Generally I think it's fair to say that the best idea is to catch exceptions as close to their source as possible, and then handle them gracefully. Textual, as you can see, has a catch-all handler that reports the error. I don't believe there's a direct method of turning it off, but you could probably override App._fatal_error (which is at the heart of this) and do something with it. For example:

import sys

from textual.app import App

class BadApp(App[None]):

    def on_mount(self) -> None:
        _ = 1/0

    def _fatal_error(self) -> None:
        super()._fatal_error()
        self._exit_renderables = []
        _, exception, _ = sys.exc_info()
        if exception is not None:
   …

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@mattthhh
Comment options

@davep
Comment options

@mattthhh
Comment options

@mattthhh
Comment options

@mattthhh
Comment options

Answer selected by mattthhh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #4278 on March 11, 2024 13:54.