DAP: Add request ID to request timeout message (#6018)

This improves error logging for dap requests. Without the ID
it's hard to know which request is the one that timed out.
This commit is contained in:
xiaoma20082008 2023-02-17 00:21:12 +08:00 committed by GitHub
parent 78a1e2db60
commit ce0837dbb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -254,7 +254,7 @@ impl Client {
// TODO: specifiable timeout, delay other calls until initialize success // TODO: specifiable timeout, delay other calls until initialize success
timeout(Duration::from_secs(20), callback_rx.recv()) timeout(Duration::from_secs(20), callback_rx.recv())
.await .await
.map_err(|_| Error::Timeout)? // return Timeout .map_err(|_| Error::Timeout(id))? // return Timeout
.ok_or(Error::StreamClosed)? .ok_or(Error::StreamClosed)?
.map(|response| response.body.unwrap_or_default()) .map(|response| response.body.unwrap_or_default())
// TODO: check response.success // TODO: check response.success

View file

@ -14,8 +14,8 @@ pub enum Error {
Parse(#[from] serde_json::Error), Parse(#[from] serde_json::Error),
#[error("IO Error: {0}")] #[error("IO Error: {0}")]
IO(#[from] std::io::Error), IO(#[from] std::io::Error),
#[error("request timed out")] #[error("request {0} timed out")]
Timeout, Timeout(u64),
#[error("server closed the stream")] #[error("server closed the stream")]
StreamClosed, StreamClosed,
#[error(transparent)] #[error(transparent)]