Skip to content

Commit 5bcd589

Browse files
committed
wrap part error info
1 parent 2a25211 commit 5bcd589

5 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/cli/gcplot.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::error::FqkitError;
12
use crate::utils::*;
23
use anyhow::{Error, Ok};
34
use bio::io::fastq;
@@ -87,7 +88,7 @@ fn plot_gc(
8788
types: &str,
8889
) -> Result<(), Error> {
8990
if !["svg", "png"].contains(&types) {
90-
error!("invalid args types.");
91+
error!("{}", FqkitError::InvalidFigureType);
9192
std::process::exit(1);
9293
}
9394
if ylim > 100 {

src/cli/grep.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::error::FqkitError;
12
use crate::utils::*;
23
use anyhow::{Ok, Result};
34
use bio::io::fastq;
@@ -29,7 +30,7 @@ pub fn grep_fastq(
2930
ids.push(id);
3031
}
3132
if ids.is_empty() {
32-
error!("no reads id in file: {}", list);
33+
error!("{}",FqkitError::EmptyFile(list.to_string()));
3334
std::process::exit(1);
3435
}
3536

src/cli/plot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::file_reader;
1+
use crate::{error::FqkitError, utils::file_reader};
22
use anyhow::Result;
33
use colored::*;
44
use log::*;
@@ -49,7 +49,7 @@ pub fn plot_line(
4949
let start = Instant::now();
5050

5151
if !["svg", "png"].contains(&types) {
52-
error!("invalid args types.");
52+
error!("{}",FqkitError::InvalidFigureType);
5353
std::process::exit(1);
5454
}
5555
let max_len = *data[0].iter().last().unwrap().0 as f32;

src/cli/stats.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::error::FqkitError;
12
use crate::utils::*;
23
use anyhow::Result;
34
use bio::io::fastq;
@@ -93,7 +94,7 @@ pub fn stat_fq(
9394
) -> Result<()> {
9495
let start = Instant::now();
9596
if ![33u8, 64u8].contains(&phred) {
96-
error!("invalid phred value");
97+
error!("{}",FqkitError::InvalidPhredValue);
9798
std::process::exit(1);
9899
}
99100

src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::io;
22
use thiserror::Error;
33

4+
45
#[derive(Debug,Error)]
56
pub enum FqkitError {
67
#[error("stdin not detected")]
@@ -18,4 +19,6 @@ pub enum FqkitError {
1819
#[error("invalid phred value")]
1920
InvalidPhredValue,
2021

22+
#[error("invalid figure types")]
23+
InvalidFigureType,
2124
}

0 commit comments

Comments
 (0)