| 1 |
use thiserror::Error; |
| 2 |
|
| 3 |
|
| 4 |
#[derive(Debug, Error)] |
| 5 |
pub enum BGZFError { |
| 6 |
|
| 7 |
#[error("Failed to parse header at position: {position}")] |
| 8 |
HeaderParseError { position: u64 }, |
| 9 |
|
| 10 |
#[error("not tabix format")] |
| 11 |
NotTabix, |
| 12 |
|
| 13 |
#[error("not BGZF format")] |
| 14 |
NotBGZF, |
| 15 |
|
| 16 |
#[error("not gzip format")] |
| 17 |
NotGzip, |
| 18 |
|
| 19 |
#[error("Too large compress unit")] |
| 20 |
TooLargeCompressUnit, |
| 21 |
|
| 22 |
#[error("I/O Error: {0}")] |
| 23 |
IoError(#[from] std::io::Error), |
| 24 |
|
| 25 |
#[error("Utf8 Error: {0}")] |
| 26 |
Utf8Error(#[from] std::str::Utf8Error), |
| 27 |
|
| 28 |
#[error("Failed to convert native path to UTF-8")] |
| 29 |
PathConvertionError, |
| 30 |
|
| 31 |
#[error("Compression Error: {0}")] |
| 32 |
CompressionError(#[from] crate::deflate::CompressError), |
| 33 |
|
| 34 |
#[error("Decompression Error: {0}")] |
| 35 |
DecompressionError(#[from] crate::deflate::DecompressError), |
| 36 |
|
| 37 |
#[error("Invalid Compression Level")] |
| 38 |
InvalidCompressionLevel, |
| 39 |
|
| 40 |
#[error("Error: {0}")] |
| 41 |
Other(&'static str), |
| 42 |
} |
| 43 |
|
| 44 |
impl Into<std::io::Error> for BGZFError { |
| 45 |
fn into(self) -> std::io::Error { |
| 46 |
match self { |
| 47 |
BGZFError::IoError(e) => e, |
| 48 |
other => std::io::Error::new(std::io::ErrorKind::Other, other), |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
impl BGZFError { |
| 54 |
pub fn into_io_error(self) -> std::io::Error { |
| 55 |
self.into() |
| 56 |
} |
| 57 |
} |