wip: more meaningful error handling

This commit is contained in:
🪞👃🪞 2025-05-20 15:38:25 +03:00
parent fc038dbd97
commit 573534a9a6
2 changed files with 22 additions and 1 deletions

View file

@ -2,6 +2,27 @@ use crate::*;
pub(crate) use std::fmt::Write;
pub(crate) use ::tengri::tui::ratatui::prelude::Position;
impl App {
pub fn view (&self) -> impl Content<TuiOut> + '_ {
let view: Perhaps<RenderBox<TuiOut>> =
FromDsl::take_from(self, &mut self.config.view.clone());
self.size.of(lay! {
When(matches!(&view, Ok(None)), Fill::y(Bsp::s(
Fixed::y(1, "no view"),
Fill::y(format!("{:?}", &self.config.view)),
))),
When(matches!(&view, Err(_)), Fill::y(Bsp::s(
Fixed::y(1, "view error"),
Fill::y(Bsp::s(
view.as_ref().err().map(|e|format!("{e}")),
format!("{:?}", &self.config.view),
))
))),
When(matches!(&view, Ok(Some(_))), Fill::y(view)),
})
}
}
#[tengri_proc::view(TuiOut)]
impl App {
pub fn view_nil (&self) -> impl Content<TuiOut> + use<'_> {