Skip to main content

htsget_config/
error.rs

1//! Error types used by this crate.
2//!
3
4use std::{io, result};
5
6use thiserror::Error;
7
8/// The result type for config.
9pub type Result<T> = result::Result<T, Error>;
10
11/// The error type for config.
12#[derive(Error, Debug, Clone, PartialEq, Eq)]
13pub enum Error {
14  #[error("io found: {0}")]
15  IoError(String),
16
17  #[error("failed to parse args found: {0}")]
18  ArgParseError(String),
19
20  #[error("failed to setup tracing: {0}")]
21  TracingError(String),
22
23  #[error("parse error: {0}")]
24  ParseError(String),
25
26  #[error("builder error: {0}")]
27  BuilderError(String),
28}
29
30impl From<Error> for io::Error {
31  fn from(error: Error) -> Self {
32    io::Error::other(error.to_string())
33  }
34}
35
36impl From<io::Error> for Error {
37  fn from(error: io::Error) -> Self {
38    Error::IoError(error.to_string())
39  }
40}
41
42impl From<serde_json::Error> for Error {
43  fn from(err: serde_json::Error) -> Self {
44    Error::ParseError(err.to_string())
45  }
46}