Skip to content

Commit

Permalink
Panic instead of log in prompt_info()
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel- committed Jun 23, 2023
1 parent 76b1027 commit bf71e82
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions crates/ark/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ pub struct PromptInfo {
user_request: bool,
}

// We prefer to panic if there is an error while trying to determine the
// prompt type because any confusion here is prone to put the frontend in a
// bad state (e.g. causing freezes)
fn prompt_info(prompt_c: *const c_char) -> PromptInfo {
let n_frame = unwrap!(harp::session::r_n_frame(), Err(err) => {
warn!("`r_n_frame()` failed: {}", err);
0
});
let n_frame = harp::session::r_n_frame().unwrap();
trace!("prompt_info(): n_frame = '{}'", n_frame);

let prompt_slice = unsafe { CStr::from_ptr(prompt_c) };
Expand All @@ -327,10 +327,7 @@ fn prompt_info(prompt_c: *const c_char) -> PromptInfo {

// The request is incomplete if we see the continue prompt, except if
// we're in a user request, e.g. `readline("+ ")`
let continue_prompt = unwrap!(unsafe { r_get_option::<String>("continue") }, Err(err) => {
warn!("`r_get_option()` failed: {}", err);
String::from("+ ")
});
let continue_prompt = unsafe { r_get_option::<String>("continue").unwrap() };
let incomplete = !user_request && prompt == continue_prompt;

if incomplete {
Expand Down

0 comments on commit bf71e82

Please sign in to comment.