Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | helix-dap/src/client.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/helix-dap/src/client.rs b/helix-dap/src/client.rs index cd1033ec..51d3bb4e 100644 --- a/helix-dap/src/client.rs +++ b/helix-dap/src/client.rs @@ -279,12 +279,20 @@ impl Client { .map_err(|e| Error::Other(e.into()))?; // TODO: specifiable timeout, delay other calls until initialize success - timeout(Duration::from_secs(20), callback_rx.recv()) + let response = timeout(Duration::from_secs(20), callback_rx.recv()) .await .map_err(|_| Error::Timeout(id))? // return Timeout - .ok_or(Error::StreamClosed)? - .map(|response| response.body.unwrap_or_default()) - // TODO: check response.success + .ok_or(Error::StreamClosed)??; + + if !response.success { + let message = response + .message + .clone() + .unwrap_or_else(|| "DAP request failed".to_string()); + return Err(Error::Other(anyhow!(message))); + } + + Ok(response.body.unwrap_or_default()) } } |