debugger beta: Improve resolve debug scenario error message (#32504)

Anthony Eid created

When no locator or valid config is found we expose the invalid config
error message to the user now.

Closes #32067 

Release Notes:

- debugger beta: Improve error message when starting a debugger session
with an invalid configuration

Change summary

crates/debugger_ui/src/session/running.rs | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

Detailed changes

crates/debugger_ui/src/session/running.rs 🔗

@@ -818,7 +818,7 @@ impl RunningState {
 
             let request_type = dap_registry
                 .adapter(&adapter)
-                .ok_or_else(|| anyhow!("{}: is not a valid adapter name", &adapter))
+                .with_context(|| format!("{}: is not a valid adapter name", &adapter))
                 .and_then(|adapter| adapter.request_kind(&config));
 
             let config_is_valid = request_type.is_ok();
@@ -932,15 +932,13 @@ impl RunningState {
             };
 
             if config_is_valid {
-                // Ok(DebugTaskDefinition {
-                //     label,
-                //     adapter: DebugAdapterName(adapter),
-                //     config,
-                //     tcp_connection,
-                // })
             } else if let Some((task, locator_name)) = build_output {
                 let locator_name =
-                    locator_name.context("Could not find a valid locator for a build task")?;
+                    locator_name.with_context(|| {
+                        format!("Could not find a valid locator for a build task and configure is invalid with error: {}", request_type.err()
+                            .map(|err| err.to_string())
+                            .unwrap_or_default())
+                    })?;
                 let request = dap_store
                     .update(cx, |this, cx| {
                         this.run_debug_locator(&locator_name, task, cx)
@@ -956,7 +954,7 @@ impl RunningState {
 
                 let scenario = dap_registry
                     .adapter(&adapter)
-                    .ok_or_else(|| anyhow!("{}: is not a valid adapter name", &adapter))
+                    .with_context(|| anyhow!("{}: is not a valid adapter name", &adapter))
                     .map(|adapter| adapter.config_from_zed_format(zed_config))??;
                 config = scenario.config;
                 Self::substitute_variables_in_config(&mut config, &task_context);