Skip to main content

openproteo_io/
error.rs

1//! Typed error for the `openproteo-io` umbrella crate.
2//!
3//! Mirrors the `thiserror`-based pattern used by `openproteo-core` and
4//! the vendor crates. Vendor-specific variants are feature-gated so
5//! that a build excluding a vendor does not carry that vendor's error
6//! type.
7
8use std::path::PathBuf;
9
10/// Errors produced by the umbrella `openproteo-io` API.
11#[derive(Debug, thiserror::Error)]
12pub enum Error {
13    /// The path did not match any supported vendor signature.
14    #[error("unsupported vendor format at {0}")]
15    UnsupportedFormat(PathBuf),
16
17    /// A vendor format was detected but its feature was not enabled at
18    /// build time.
19    #[error("openproteo-io was built without the '{vendor}' feature")]
20    FeatureDisabled { vendor: &'static str },
21
22    /// Wrapping I/O error.
23    #[error(transparent)]
24    Io(#[from] std::io::Error),
25
26    /// Wrapping `openproteo-core` error.
27    #[error(transparent)]
28    Core(#[from] openproteo_core::Error),
29
30    /// Thermo (`opentfraw`) error.
31    #[cfg(feature = "thermo")]
32    #[error(transparent)]
33    Thermo(#[from] opentfraw::Error),
34
35    /// Bruker (`opentimstdf`) error.
36    #[cfg(feature = "bruker")]
37    #[error(transparent)]
38    Bruker(#[from] opentimstdf::Error),
39
40    /// Waters (`openwraw`) error.
41    #[cfg(feature = "waters")]
42    #[error(transparent)]
43    Waters(#[from] openwraw::Error),
44
45    /// mzML parsing error. Kept as a string until `mzdata` exposes a
46    /// typed error suitable for `#[from]`.
47    #[error("mzML error: {0}")]
48    Mzml(String),
49}
50
51/// Convenience alias mirroring the vendor crates.
52pub type Result<T> = std::result::Result<T, Error>;