Surface serde error detail in sync handshake failure

Amolith created

Change summary

src/cmd/sync.rs | 8 ++++++--
src/main.rs     | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)

Detailed changes

src/cmd/sync.rs 🔗

@@ -93,7 +93,9 @@ pub async fn exchange(store: &db::Store, mut wormhole: Wormhole) -> Result<SyncR
         .receive_json::<SyncHandshake>()
         .await
         .context("failed to receive handshake")?
-        .context("peer sent invalid handshake JSON")?;
+        .context(
+            "peer sent incompatible handshake (are both sides running the same version of td?)",
+        )?;
 
     let their_vv = match &their_handshake {
         SyncHandshake::Sync {
@@ -209,7 +211,9 @@ async fn bootstrap_exchange(
         .receive_json::<SyncHandshake>()
         .await
         .context("failed to receive handshake")?
-        .context("peer sent invalid handshake JSON")?;
+        .context(
+            "peer sent incompatible handshake (are both sides running the same version of td?)",
+        )?;
 
     let project_name = match their_handshake {
         SyncHandshake::Sync { project_name, .. } => project_name,

src/main.rs 🔗

@@ -4,6 +4,9 @@ fn main() {
     if let Err(e) = yatd::run() {
         let c = yatd::color::stderr_theme();
         eprintln!("{}error:{} {e}", c.red, c.reset);
+        for cause in e.chain().skip(1) {
+            eprintln!("{}caused by:{} {cause}", c.red, c.reset);
+        }
         process::exit(1);
     }
 }