@@ -475,19 +475,36 @@ pub fn dap_variables(cx: &mut Context) {
475475
476476 if debugger.thread_id.is_none() {
477477 cx.editor
478− .set_status("Cannot access variables while target is running");
478+ .set_status("Cannot access variables while target is running.");
479479 return;
480480 }
481481 let (frame, thread_id) = match (debugger.active_frame, debugger.thread_id) {
482482 (Some(frame), Some(thread_id)) => (frame, thread_id),
483483 _ => {
484484 cx.editor
485− .set_status("Cannot find current stack frame to access variables");
485+ .set_status("Cannot find current stack frame to access variables.");
486486 return;
487487 }
488488 };
489489
490− let frame_id = debugger.stack_frames[&thread_id][frame].id;
490+ let thread_frame = match debugger.stack_frames.get(&thread_id) {
491+ Some(thread_frame) => thread_frame,
492+ None => {
493+ cx.editor
494+ .set_error("Failed to get stack frame for thread: {thread_id}");
495+ return;
496+ }
497+ };
498+ let stack_frame = match thread_frame.get(frame) {
499+ Some(stack_frame) => stack_frame,
500+ None => {
501+ cx.editor
502+ .set_error("Failed to get stack frame for thread {thread_id} and frame {frame}.");
503+ return;
504+ }
505+ };
506+
507+ let frame_id = stack_frame.id;
491508 let scopes = match block_on(debugger.scopes(frame_id)) {
492509 Ok(s) => s,
493510 Err(e) => {