Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch exceptions from post mount #1887

Merged
merged 1 commit into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/textual/dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/textual/message_pump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
4 changes: 3 additions & 1 deletion src/textual/reactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")()
Expand All @@ -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)

Expand Down