aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKevin Hoerr <kjhoerr@submelon.dev>2026-03-02 23:07:06 +0000
committerKevin Hoerr <kjhoerr@submelon.dev>2026-03-02 23:07:06 +0000
commit541c6c3168b2fa1fc8f6a59fd668ea8fc337f1fb (patch)
tree8c409836bad2b1c0f93f873c3bb9ebb2b5492edc /src
parente0653a14e28ca6a7d6a8686c95785461df01b52f (diff)
downloadequity-tracker-541c6c3168b2fa1fc8f6a59fd668ea8fc337f1fb.tar.gz
equity-tracker-541c6c3168b2fa1fc8f6a59fd668ea8fc337f1fb.tar.bz2
equity-tracker-541c6c3168b2fa1fc8f6a59fd668ea8fc337f1fb.zip
main.rs: Call App to set and clear error
Diffstat (limited to 'src')
-rw-r--r--src/main/rust/main.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main/rust/main.rs b/src/main/rust/main.rs
index 043702c..dad7f7c 100644
--- a/src/main/rust/main.rs
+++ b/src/main/rust/main.rs
@@ -55,7 +55,11 @@ fn run_app<B: Backend>(term: &mut Terminal<B>, app: &mut App) -> Result<()> {
// it's important to check that the event is a key press event as
// crossterm also emits key release and repeat events on Windows.
Event::Key(key_event) if key_event.kind == KeyEventKind::Press => {
- handle_key_event(app, key_event)?;
+ // if error occurred during input processing, set error in the app state
+ match handle_key_event(app, key_event) {
+ Err(e) => app.set_error(e)?,
+ _ => {}
+ }
}
_ => {}
};
@@ -71,6 +75,8 @@ fn handle_key_event(app: &mut App, key_event: KeyEvent) -> Result<()> {
KeyCode::Right => app.increment_counter()?,
_ => {}
};
+ // any new key event, we should clear the existing error
+ app.clear_error()?;
Ok(())
}