Skip to content

Commit f814dac

Browse files
committed
Improve error message
1 parent c2358b1 commit f814dac

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/app.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::sync::{mpsc, Arc, atomic::{AtomicI32, self}};
22

33
use log::{warn, info, debug};
4-
use anyhow::Result;
4+
use anyhow::{Result, Context};
55
use serde_json as json;
66

77
use crate::{rpcio, bytecode::{self, BytecodeOptions}};
@@ -122,28 +122,36 @@ pub fn run_app_forever(client_reader: impl std::io::Read + Send + 'static,
122122
let proc_stdin = proc.stdin.take().unwrap();
123123
std::thread::spawn(move || {
124124
debug!("Started client->server write thread");
125-
process_channel_to_writer(c2s_channel_sub, Some(c2s_channel_counter), proc_stdin).unwrap();
125+
process_channel_to_writer(c2s_channel_sub, Some(c2s_channel_counter), proc_stdin)
126+
.with_context(|| "Client->server write thread failed")
127+
.unwrap();
126128
debug!("Finished client->server write thread");
127129
});
128130
}
129131
std::thread::spawn(move || {
130132
debug!("Started server->client write thread");
131-
process_channel_to_writer(s2c_channel_sub, None, client_writer).unwrap();
133+
process_channel_to_writer(s2c_channel_sub, None, client_writer)
134+
.with_context(|| "Server->client write thread failed")
135+
.unwrap();
132136
debug!("Finished server->client write thread");
133137
});
134138
{
135139
let s2c_channel_pub = s2c_channel_pub.clone();
136140
let proc_stdout = proc.stdout.take().unwrap();
137141
std::thread::spawn(move || {
138142
debug!("Started server->client read thread");
139-
process_server_reader(proc_stdout, s2c_channel_pub, options.bytecode_options).unwrap();
143+
process_server_reader(proc_stdout, s2c_channel_pub, options.bytecode_options)
144+
.with_context(|| "Server->client read thread failed")
145+
.unwrap();
140146
debug!("Finished server->client read thread");
141147
});
142148
}
143149
std::thread::spawn(move || {
144150
debug!("Started client->server read thread");
145151
process_client_reader(
146-
client_reader, c2s_channel_pub, c2s_channel_counter, s2c_channel_pub).unwrap();
152+
client_reader, c2s_channel_pub, c2s_channel_counter, s2c_channel_pub)
153+
.with_context(|| "Client->server read thread failed")
154+
.unwrap();
147155
debug!("Finished client->server read thread");
148156
});
149157

0 commit comments

Comments
 (0)