Improve error messages when extools is disabled

This commit is contained in:
Tad Hardesty 2019-11-29 20:45:19 -08:00
parent 2125c0c417
commit dfb77db16e

View file

@ -179,15 +179,19 @@ handle_request! {
if let Some(thread) = extools.get_thread(params.threadId) {
return Ok(StackTraceResponse {
totalFrames: Some(thread.call_stack.len() as i64),
stackFrames: thread.call_stack.into_iter().map(|name| StackFrame {
stackFrames: thread.call_stack.into_iter().enumerate().map(|(i, name)| StackFrame {
name,
// TODO: id, source, line
id: i as i64,
// TODO: source, line
.. Default::default()
}).collect(),
});
} else {
return Err(GenericError("Bad thread ID passed"));
}
} else {
return Err(GenericError("No extools connection"));
}
return Err(Box::new(std::io::Error::from(std::io::ErrorKind::InvalidData)));
}
}
@ -246,6 +250,19 @@ impl SequenceNumber {
}
}
#[derive(Debug)]
struct GenericError(&'static str);
impl Error for GenericError {
fn description(&self) -> &str { self.0 }
}
impl std::fmt::Display for GenericError {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
fmt.write_str(self.0)
}
}
// ----------------------------------------------------------------------------
// Implementation-specific DAP extensions.