openmassspec_io/error.rs
1//! Typed error for the `openmassspec-io` umbrella crate.
2//!
3//! Mirrors the `thiserror`-based pattern used by `openmassspec-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 `openmassspec-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("openmassspec-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 `openmassspec-core` error.
27 #[error(transparent)]
28 Core(#[from] openmassspec_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 /// Agilent (`openaraw`) error.
46 #[cfg(feature = "agilent")]
47 #[error(transparent)]
48 Agilent(#[from] openaraw::Error),
49
50 /// SCIEX (`opensxraw`) error.
51 #[cfg(feature = "sciex")]
52 #[error(transparent)]
53 Sciex(#[from] opensxraw::Error),
54
55 /// mzML parsing error. Kept as a string until `mzdata` exposes a
56 /// typed error suitable for `#[from]`.
57 #[error("mzML error: {0}")]
58 Mzml(String),
59}
60
61/// Convenience alias mirroring the vendor crates.
62pub type Result<T> = std::result::Result<T, Error>;