perbase icon indicating copy to clipboard operation
perbase copied to clipboard

Missing bam/cram file should return an error code

Open patbohn opened this issue 3 years ago • 2 comments

Hi, when running perbase base-depth with an incorrect BAM/CRAM path, even though stderr reports thread '<unnamed>' panicked at 'Indexed BAM/CRAM: FileNotFound [...] perbase/src/lib/par_granges.rs:159:72, it seems that no error code was returned (i.e. it apparently returned 0). This can be an issue when using pipeline or workload managers.

patbohn avatar Sep 29 '22 11:09 patbohn

Thanks for making this issue! I look into it and get an update out in the near future. That is definitely not the desired behavior, it should exit > 0.👍

sstadick avatar Sep 29 '22 23:09 sstadick

Small bump - I think what's happening here is that while you're catching any Error returned here:

https://github.com/sstadick/perbase/blob/abdfb7595ac8c42cc24d93b80175fb3e4585d7c6/src/main.rs#L38

A missing file will not return an Error, but just panic due to the .expect() call here:

https://github.com/sstadick/perbase/blob/abdfb7595ac8c42cc24d93b80175fb3e4585d7c6/src/lib/par_granges.rs#L159

For the specific call in granges I suppose returning the Error early should work as the output of the process_region function is already a Result type.

nano-pat avatar Jun 27 '24 08:06 nano-pat