diff --git a/CHANGELOG.md b/CHANGELOG.md index 64be93e2f0..6eed955935 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - `MouseScrollUp` and `MouseScrollDown` now inherit from `MouseEvent` and have attached modifier keys. https://github.com/Textualize/textual/pull/1458 +- Fail-fast and print pretty tracebacks for Widget compose errors https://github.com/Textualize/textual/pull/1505 ### Fixed diff --git a/src/textual/widget.py b/src/textual/widget.py index 65ff0bc0d5..185d18a64d 100644 --- a/src/textual/widget.py +++ b/src/textual/widget.py @@ -33,6 +33,7 @@ from rich.segment import Segment from rich.style import Style from rich.text import Text +from rich.traceback import Traceback from . import errors, events, messages from ._animator import DEFAULT_EASING, Animatable, BoundAnimator, EasingFunction @@ -2333,7 +2334,10 @@ async def _on_compose(self) -> None: raise TypeError( f"{self!r} compose() returned an invalid response; {error}" ) from None - await self.mount(*widgets) + except Exception: + self.app.panic(Traceback()) + else: + await self.mount(*widgets) def _on_mount(self, event: events.Mount) -> None: if self.styles.overflow_y == "scroll":