Skip to content

Commit

Permalink
signer: Return a wrapped error, don't overwrite it
Browse files Browse the repository at this point in the history
Investigating an issue when calling `maybe_upgrade` and it turns out
we were just overwriting the message with a generic one that wasn't
telling us much.
  • Loading branch information
cdecker committed Aug 16, 2023
1 parent 22bf988 commit 795af9b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions libs/gl-client/src/signer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::pb::scheduler::{scheduler_client::SchedulerClient, NodeInfoRequest, U
use crate::pb::{node_client::NodeClient, Empty, HsmRequest, HsmRequestContext, HsmResponse};
use crate::tls::TlsConfig;
use crate::{node, node::Client};
use anyhow::{anyhow, Context};
use anyhow::anyhow;
use bytes::{Buf, BufMut, Bytes};
use http::uri::InvalidUri;
use lightning_signer::bitcoin::Network;
Expand Down Expand Up @@ -63,6 +63,9 @@ pub enum Error {
#[error("scheduler returned faulty URI: {0}")]
InvalidUri(#[from] InvalidUri),

#[error("signer refused a request: {0}")]
Signer(#[from] vls_protocol::Error),

#[error("other: {0}")]
Other(anyhow::Error),
}
Expand Down Expand Up @@ -325,9 +328,8 @@ impl Signer {
)));
}

let msg = vls_protocol::msgs::from_vec(req.raw)
.context("parsing request")
.map_err(|e| Error::Other(e))?;
let msg = vls_protocol::msgs::from_vec(req.raw).map_err(|e|
Error::Signer(e))?;

log::trace!("Handling message {:?}", msg);

Expand Down Expand Up @@ -464,7 +466,7 @@ impl Signer {
.collect(),
})
.await
.context("Error asking scheduler to upgrade")?;
.map_err(|e| anyhow!("error asking scheduler to upgrade: {}", e))?;

loop {
debug!("Calling scheduler.get_node_info");
Expand Down

0 comments on commit 795af9b

Please sign in to comment.