Skip to content

Commit

Permalink
Improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
blahgeek committed Jan 14, 2024
1 parent c2358b1 commit f814dac
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::{mpsc, Arc, atomic::{AtomicI32, self}};

use log::{warn, info, debug};
use anyhow::Result;
use anyhow::{Result, Context};
use serde_json as json;

use crate::{rpcio, bytecode::{self, BytecodeOptions}};
Expand Down Expand Up @@ -122,28 +122,36 @@ pub fn run_app_forever(client_reader: impl std::io::Read + Send + 'static,
let proc_stdin = proc.stdin.take().unwrap();
std::thread::spawn(move || {
debug!("Started client->server write thread");
process_channel_to_writer(c2s_channel_sub, Some(c2s_channel_counter), proc_stdin).unwrap();
process_channel_to_writer(c2s_channel_sub, Some(c2s_channel_counter), proc_stdin)
.with_context(|| "Client->server write thread failed")
.unwrap();
debug!("Finished client->server write thread");
});
}
std::thread::spawn(move || {
debug!("Started server->client write thread");
process_channel_to_writer(s2c_channel_sub, None, client_writer).unwrap();
process_channel_to_writer(s2c_channel_sub, None, client_writer)
.with_context(|| "Server->client write thread failed")
.unwrap();
debug!("Finished server->client write thread");
});
{
let s2c_channel_pub = s2c_channel_pub.clone();
let proc_stdout = proc.stdout.take().unwrap();
std::thread::spawn(move || {
debug!("Started server->client read thread");
process_server_reader(proc_stdout, s2c_channel_pub, options.bytecode_options).unwrap();
process_server_reader(proc_stdout, s2c_channel_pub, options.bytecode_options)
.with_context(|| "Server->client read thread failed")
.unwrap();
debug!("Finished server->client read thread");
});
}
std::thread::spawn(move || {
debug!("Started client->server read thread");
process_client_reader(
client_reader, c2s_channel_pub, c2s_channel_counter, s2c_channel_pub).unwrap();
client_reader, c2s_channel_pub, c2s_channel_counter, s2c_channel_pub)
.with_context(|| "Client->server read thread failed")
.unwrap();
debug!("Finished client->server read thread");
});

Expand Down

0 comments on commit f814dac

Please sign in to comment.