Skip to content

Commit

Permalink
Fix interprerter error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ales-tsurko committed Oct 27, 2024
1 parent 5c6acc2 commit 8411548
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
33 changes: 19 additions & 14 deletions src/app/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,21 +242,26 @@ pub fn view(state: &State) -> Element<Message> {
}

fn view_top_panel(state: &State) -> Element<Message> {
row![
button(text("").font(iced_fonts::NERD_FONT).size(16.0))
.style(button::text)
.on_press(Message::SetScratchDir),
text(&state.scratch_dir),
horizontal_space(),
text("Tempo:"),
number_input(state.midi_player_state.tempo(), 20..=600, Message::SetTempo,)
.step(1)
.width(60.0),
text("BPM"),
column![
row![
horizontal_space(),
text("Tempo:"),
number_input(state.midi_player_state.tempo(), 20..=600, Message::SetTempo,)
.step(1)
.width(60.0),
text("BPM"),
]
.spacing(10.0)
.align_y(iced::Alignment::Center),
row![
button(text("").font(iced_fonts::NERD_FONT).size(16.0))
.style(button::text)
.on_press(Message::SetScratchDir),
text(&state.scratch_dir),
]
.spacing(10.0)
.align_y(iced::Alignment::Center),
]
.spacing(10.0)
.align_y(iced::Alignment::Center)
.height(40.0)
.into()
}

Expand Down
12 changes: 10 additions & 2 deletions src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ impl InterpreterWorker {
.map(|_| Message::ScratchDir(value)),
_ => continue,
}
.map_err(Into::<Message>::into)
.unwrap();
.into();

s.send_blocking(msg).expect("cannot send message to gui");
}
Expand Down Expand Up @@ -115,6 +114,15 @@ impl From<Error> for Message {
}
}

impl From<InterpreterResult<Message>> for Message {
fn from(value: InterpreterResult<Message>) -> Self {
match value {
Ok(msg) => msg,
Err(e) => Self::from(e),
}
}
}

struct Interpreter {
py_interpreter: PyInterpreter,
ath_interpreter: PyObjectRef,
Expand Down

0 comments on commit 8411548

Please sign in to comment.