Skip to content

Commit 4fb737a

Browse files
committed
Propagate errors
1 parent 958ecd2 commit 4fb737a

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/f2m.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,9 @@ fn fcount(
271271
if !peak_cell_counts.is_empty() {
272272
// send counts to writer thread, replace with empty hashmap
273273
let counts_to_send = std::mem::replace(&mut peak_cell_counts, FxHashMap::default());
274-
if counts_tx.send((counts_to_send, false)).is_err() {
275-
break;
274+
if let Err(e) = counts_tx.send((counts_to_send, false)) {
275+
error!("Failed to send chromosome counts: {}", e);
276+
return Err(io::Error::new(io::ErrorKind::Other, e));
276277
}
277278
}
278279
}
@@ -339,21 +340,19 @@ fn fcount(
339340
}
340341
}
341342

343+
// Wait for reader thread to complete
344+
reader_handle.join().expect("Reader thread panicked");
345+
342346
// Send final counts and signal completion
343347
nonzero_counts += peak_cell_counts.len() as u64;
344348
let final_counts = std::mem::replace(&mut peak_cell_counts, FxHashMap::default());
345349
if let Err(e) = counts_tx.send((final_counts, true)) {
346350
error!("Failed to send final counts: {}", e);
347351
return Err(io::Error::new(io::ErrorKind::Other, e));
348352
}
349-
drop(counts_tx);
350353

351-
// Wait for writer and reader threads to complete
352-
reader_handle.join().expect("Reader thread panicked");
353-
if let Err(e) = writer_handle.join() {
354-
error!("Writer thread panicked: {:?}", e);
355-
return Err(io::Error::new(io::ErrorKind::Other, "Writer thread panicked"));
356-
}
354+
// Wait for writer thread to complete
355+
writer_handle.join().expect("Writer thread panicked");
357356

358357
// write mtx header with proper gzip compression
359358
info!("Writing output counts file: {:?}", &output.join("matrix.mtx.gz"));

0 commit comments

Comments
 (0)