Skip to content

Commit

Permalink
fix: JSON parse error doesn't crash
Browse files Browse the repository at this point in the history
  • Loading branch information
ActuallyHappening committed Jul 11, 2023
1 parent f0598eb commit a1b9ec7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/board/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a1b9ec7

Please sign in to comment.