Skip to content

Commit

Permalink
vcf/variant/record_buf/samples/sample: Remove GenotypeError
Browse files Browse the repository at this point in the history
  • Loading branch information
zaeleus committed Feb 21, 2024
1 parent 7731c29 commit 202e4bb
Showing 1 changed file with 2 additions and 32 deletions.
34 changes: 2 additions & 32 deletions noodles-vcf/src/variant/record_buf/samples/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
pub mod value;

pub use self::value::Value;

use std::{error, fmt, hash::Hash};
use std::hash::Hash;

pub use self::value::Value;
use super::Keys;

/// A VCF record genotype sample.
Expand Down Expand Up @@ -41,32 +40,3 @@ impl<'g> Sample<'g> {
.and_then(|i| self.values.get(i).map(|value| value.as_ref()))
}
}

/// An error returned when a genotype (`GT`) field value fails to parse.
#[derive(Clone, Debug, PartialEq)]
pub enum GenotypeError {
/// The genotype field value is invalid.
InvalidValue(value::genotype::ParseError),
/// The genotype field value type is invalid.
///
/// The `GT` field value must be a `String`.
InvalidValueType(Option<Value>),
}

impl error::Error for GenotypeError {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
Self::InvalidValue(e) => Some(e),
Self::InvalidValueType(_) => None,
}
}
}

impl fmt::Display for GenotypeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidValue(_) => f.write_str("invalid value"),
Self::InvalidValueType(value) => write!(f, "invalid String, got {value:?}"),
}
}
}

0 comments on commit 202e4bb

Please sign in to comment.