Exit debug (#2554)

* show single error by default

* changelog

* show numbers of errors

* changelog
This commit is contained in:
Will McGugan
2023-05-16 21:34:34 +01:00
committed by GitHub
parent abb7705ed0
commit 3a17a76233
2 changed files with 17 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed ### Changed
- App `title` and `sub_title` attributes can be set to any type https://github.com/Textualize/textual/issues/2521 - App `title` and `sub_title` attributes can be set to any type https://github.com/Textualize/textual/issues/2521
- Only a single error will be written by default, unless in dev mode ("debug" in App.features) https://github.com/Textualize/textual/issues/2480
- Using `Widget.move_child` where the target and the child being moved are the same is now a no-op https://github.com/Textualize/textual/issues/1743 - Using `Widget.move_child` where the target and the child being moved are the same is now a no-op https://github.com/Textualize/textual/issues/1743
- Calling `dismiss` on a screen that is not at the top of the stack now raises an exception https://github.com/Textualize/textual/issues/2575 - Calling `dismiss` on a screen that is not at the top of the stack now raises an exception https://github.com/Textualize/textual/issues/2575
- `MessagePump.call_after_refresh` and `MessagePump.call_later` will not return `False` if the callback could not be scheduled. https://github.com/Textualize/textual/pull/2584 - `MessagePump.call_after_refresh` and `MessagePump.call_later` will not return `False` if the callback could not be scheduled. https://github.com/Textualize/textual/pull/2584

View File

@@ -1630,8 +1630,22 @@ class App(Generic[ReturnType], DOMNode):
def _print_error_renderables(self) -> None: def _print_error_renderables(self) -> None:
"""Print and clear exit renderables.""" """Print and clear exit renderables."""
for renderable in self._exit_renderables: error_count = len(self._exit_renderables)
self.error_console.print(renderable) if "debug" in self.features:
for renderable in self._exit_renderables:
self.error_console.print(renderable)
if error_count > 1:
self.error_console.print(
f"\n[b]NOTE:[/b] {error_count} errors show above.", markup=True
)
elif self._exit_renderables:
self.error_console.print(self._exit_renderables[0])
if error_count > 1:
self.error_console.print(
f"\n[b]NOTE:[/b] 1 of {error_count} errors show. Run with [b]--dev[/] to see all errors.",
markup=True,
)
self._exit_renderables.clear() self._exit_renderables.clear()
async def _process_messages( async def _process_messages(