From a1b9ec7904f4c11b9d46fe1d9bccede359bf402f Mon Sep 17 00:00:00 2001 From: ActuallyHappening <105958073+ActuallyHappening@users.noreply.github.com> Date: Wed, 12 Jul 2023 07:53:02 +1000 Subject: [PATCH] fix: JSON parse error doesn't crash --- src/board/ui.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/board/ui.rs b/src/board/ui.rs index b7b60bd..09da2b3 100644 --- a/src/board/ui.rs +++ b/src/board/ui.rs @@ -156,7 +156,14 @@ pub fn left_sidebar_ui( // copy + paste functionality let mut state_str = current_moves.to_json(); if ui.text_edit_singleline(&mut state_str).changed() { - *current_moves = ManualMoves::try_from(state_str).expect("To be able to convert string to moves"); + match ManualMoves::try_from(state_str) { + Ok(moves) => { + *current_moves = moves; + } + Err(e) => { + warn!("Could not parse state JSON string: {}", e); + } + } } // undo button