mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Merge pull request #1887 from Textualize/exceptions-from-mount
catch exceptions from post mount
This commit is contained in:
@@ -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/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
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
|
## [0.12.1] - 2023-02-25
|
||||||
|
|
||||||
|
|||||||
@@ -221,6 +221,7 @@ class DOMNode(MessagePump):
|
|||||||
|
|
||||||
def _post_mount(self):
|
def _post_mount(self):
|
||||||
"""Called after the object has been mounted."""
|
"""Called after the object has been mounted."""
|
||||||
|
_rich_traceback_omit = True
|
||||||
Reactive._initialize_object(self)
|
Reactive._initialize_object(self)
|
||||||
|
|
||||||
def notify_style_update(self) -> None:
|
def notify_style_update(self) -> None:
|
||||||
|
|||||||
@@ -429,12 +429,12 @@ class MessagePump(metaclass=MessagePumpMeta):
|
|||||||
try:
|
try:
|
||||||
await self._dispatch_message(events.Compose(sender=self))
|
await self._dispatch_message(events.Compose(sender=self))
|
||||||
await self._dispatch_message(events.Mount(sender=self))
|
await self._dispatch_message(events.Mount(sender=self))
|
||||||
|
self._post_mount()
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
self.app._handle_exception(error)
|
self.app._handle_exception(error)
|
||||||
finally:
|
finally:
|
||||||
# This is critical, mount may be waiting
|
# This is critical, mount may be waiting
|
||||||
self._mounted_event.set()
|
self._mounted_event.set()
|
||||||
self._post_mount()
|
|
||||||
|
|
||||||
def _post_mount(self):
|
def _post_mount(self):
|
||||||
"""Called after the object has been mounted."""
|
"""Called after the object has been mounted."""
|
||||||
|
|||||||
@@ -89,10 +89,12 @@ class Reactive(Generic[ReactiveType]):
|
|||||||
obj: An object with reactive attributes.
|
obj: An object with reactive attributes.
|
||||||
name: Name of attribute.
|
name: Name of attribute.
|
||||||
"""
|
"""
|
||||||
|
_rich_traceback_omit = True
|
||||||
internal_name = f"_reactive_{name}"
|
internal_name = f"_reactive_{name}"
|
||||||
if hasattr(obj, internal_name):
|
if hasattr(obj, internal_name):
|
||||||
# Attribute already has a value
|
# Attribute already has a value
|
||||||
return
|
return
|
||||||
|
|
||||||
compute_method = getattr(obj, f"compute_{name}", None)
|
compute_method = getattr(obj, f"compute_{name}", None)
|
||||||
if compute_method is not None and self._init:
|
if compute_method is not None and self._init:
|
||||||
default = getattr(obj, f"compute_{name}")()
|
default = getattr(obj, f"compute_{name}")()
|
||||||
@@ -114,7 +116,7 @@ class Reactive(Generic[ReactiveType]):
|
|||||||
Args:
|
Args:
|
||||||
obj: An object with Reactive descriptors
|
obj: An object with Reactive descriptors
|
||||||
"""
|
"""
|
||||||
|
_rich_traceback_omit = True
|
||||||
for name, reactive in obj._reactives.items():
|
for name, reactive in obj._reactives.items():
|
||||||
reactive._initialize_reactive(obj, name)
|
reactive._initialize_reactive(obj, name)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user