@@ -1,6 +1,6 @@
1use crate::{Error, Result};
1use crate::{Error, Result};
2use anyhow::Context;
2use anyhow::Context;
3−use log::{error, info};
3+use log::{error, info, warn};
4use serde::{Deserialize, Serialize};
4use serde::{Deserialize, Serialize};
5use serde_json::Value;
5use serde_json::Value;
6use std::collections::HashMap;
6use std::collections::HashMap;
@@ -162,54 +162,50 @@ impl Transport {
165+ fn process_response(res: Response) -> Result<Response> {
169+ "<- DAP success ({}, in response to {})",
170+ res.seq, res.request_seq
177+ "<- DAP error {:?} ({:?}) for command #{} {}",
178+ res.message, res.body, res.request_seq, res.command
181+ Err(Error::Other(anyhow::format_err!("{:?}", res.body)))
165 async fn process_server_message(
186 async fn process_server_message(
167 client_tx: &UnboundedSender<Payload>,
188 client_tx: &UnboundedSender<Payload>,
168 msg: Payload,
189 msg: Payload,
169 ) -> Result<()> {
190 ) -> Result<()> {
170 match msg {
191 match msg {
171− Payload::Response(Response {
192+ Payload::Response(res) => {
174− request_seq,
193+ let request_seq = res.request_seq;
175− ref command,
194+ let tx = self.pending_requests.lock().await.remove(&request_seq);
177− ref body,
196+ match tx {
178− ..
197+ Some(tx) => match tx.send(Self::process_response(res)).await {
179− }) => {
198+ Ok(_) => (),
180− let result = match success {
199+ Err(_) => error!(
181− true => {
200+ "Tried sending response into a closed channel (id={:?}), original request likely timed out",
182− info!("<- DAP success ({}, in response to {})", seq, request_seq);
201+ request_seq
183− if let Payload::Response(val) = msg {
202+ ),
189− false => {
204+ None => {
190− error!(
205+ warn!("Response to nonexistent request #{}", res.request_seq);
191− "<- DAP error {:?} ({:?}) for command #{} {}",
206+ client_tx.send(Payload::Response(res)).expect("Failed to send");
192− message, body, request_seq, command
195− Err(Error::Other(anyhow::format_err!("{:?}", body)))
203− .remove(&request_seq)
204− .expect("pending_request with id not found!");
206− match tx.send(result).await {
209− "Tried sending response into a closed channel (id={:?}), original request likely timed out",