Skip to content

Commit

Permalink
wrap part error info
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkLoc committed May 15, 2024
1 parent 2a25211 commit 5bcd589
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/cli/gcplot.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::error::FqkitError;
use crate::utils::*;
use anyhow::{Error, Ok};
use bio::io::fastq;
Expand Down Expand Up @@ -87,7 +88,7 @@ fn plot_gc(
types: &str,
) -> Result<(), Error> {
if !["svg", "png"].contains(&types) {
error!("invalid args types.");
error!("{}", FqkitError::InvalidFigureType);
std::process::exit(1);
}
if ylim > 100 {
Expand Down
3 changes: 2 additions & 1 deletion src/cli/grep.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::error::FqkitError;
use crate::utils::*;
use anyhow::{Ok, Result};
use bio::io::fastq;
Expand Down Expand Up @@ -29,7 +30,7 @@ pub fn grep_fastq(
ids.push(id);
}
if ids.is_empty() {
error!("no reads id in file: {}", list);
error!("{}",FqkitError::EmptyFile(list.to_string()));
std::process::exit(1);
}

Expand Down
4 changes: 2 additions & 2 deletions src/cli/plot.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::utils::file_reader;
use crate::{error::FqkitError, utils::file_reader};
use anyhow::Result;
use colored::*;
use log::*;
Expand Down Expand Up @@ -49,7 +49,7 @@ pub fn plot_line(
let start = Instant::now();

if !["svg", "png"].contains(&types) {
error!("invalid args types.");
error!("{}",FqkitError::InvalidFigureType);
std::process::exit(1);
}
let max_len = *data[0].iter().last().unwrap().0 as f32;
Expand Down
3 changes: 2 additions & 1 deletion src/cli/stats.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::error::FqkitError;
use crate::utils::*;
use anyhow::Result;
use bio::io::fastq;
Expand Down Expand Up @@ -93,7 +94,7 @@ pub fn stat_fq(
) -> Result<()> {
let start = Instant::now();
if ![33u8, 64u8].contains(&phred) {
error!("invalid phred value");
error!("{}",FqkitError::InvalidPhredValue);
std::process::exit(1);
}

Expand Down
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::io;
use thiserror::Error;


#[derive(Debug,Error)]
pub enum FqkitError {
#[error("stdin not detected")]
Expand All @@ -18,4 +19,6 @@ pub enum FqkitError {
#[error("invalid phred value")]
InvalidPhredValue,

#[error("invalid figure types")]
InvalidFigureType,
}

0 comments on commit 5bcd589

Please sign in to comment.