diff --git a/CHANGELOG.md b/CHANGELOG.md index 097ac54b65..706651f229 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## Unreleased + +### Fixed + +- Fix exceptions in watch methods being hidden on startup https://github.com/Textualize/textual/issues/1886 ## [0.12.1] - 2023-02-25 diff --git a/src/textual/dom.py b/src/textual/dom.py index 9980c94716..829b36796c 100644 --- a/src/textual/dom.py +++ b/src/textual/dom.py @@ -221,6 +221,7 @@ def get_component_styles(self, name: str) -> RenderStyles: def _post_mount(self): """Called after the object has been mounted.""" + _rich_traceback_omit = True Reactive._initialize_object(self) def notify_style_update(self) -> None: diff --git a/src/textual/message_pump.py b/src/textual/message_pump.py index 7a2f6d24ec..448df53236 100644 --- a/src/textual/message_pump.py +++ b/src/textual/message_pump.py @@ -429,12 +429,12 @@ async def _pre_process(self) -> None: try: await self._dispatch_message(events.Compose(sender=self)) await self._dispatch_message(events.Mount(sender=self)) + self._post_mount() except Exception as error: self.app._handle_exception(error) finally: # This is critical, mount may be waiting self._mounted_event.set() - self._post_mount() def _post_mount(self): """Called after the object has been mounted.""" diff --git a/src/textual/reactive.py b/src/textual/reactive.py index 927b6a8456..5942809f1d 100644 --- a/src/textual/reactive.py +++ b/src/textual/reactive.py @@ -89,10 +89,12 @@ def _initialize_reactive(self, obj: Reactable, name: str) -> None: obj: An object with reactive attributes. name: Name of attribute. """ + _rich_traceback_omit = True internal_name = f"_reactive_{name}" if hasattr(obj, internal_name): # Attribute already has a value return + compute_method = getattr(obj, f"compute_{name}", None) if compute_method is not None and self._init: default = getattr(obj, f"compute_{name}")() @@ -114,7 +116,7 @@ def _initialize_object(cls, obj: Reactable) -> None: Args: obj: An object with Reactive descriptors """ - + _rich_traceback_omit = True for name, reactive in obj._reactives.items(): reactive._initialize_reactive(obj, name)