1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Error types for the primer3 crate.
use thiserror::Error;
/// Errors that can occur when using the primer3 library.
#[derive(Debug, Error)]
pub enum Primer3Error {
/// The primer3 C library returned an error message.
#[error("primer3 error: {0}")]
Library(Box<str>),
/// Failed to initialize thermodynamic parameters.
#[error("failed to initialize thermodynamic parameters: {0}")]
InitFailed(Box<str>),
/// The input sequence is invalid (empty, contains non-DNA characters, etc.).
#[error("invalid sequence: {0}")]
InvalidSequence(Box<str>),
/// The input sequence exceeds the maximum allowed length.
#[error("sequence length {length} exceeds maximum {max} for {operation}")]
SequenceTooLong { length: usize, max: usize, operation: &'static str },
/// A design constraint is invalid (e.g., min > max).
#[error("invalid setting: {0}")]
InvalidSetting(String),
/// Global errors from the primer design engine.
#[error("primer design global error: {0}")]
DesignGlobalError(Box<str>),
/// Per-sequence errors from the primer design engine.
#[error("primer design sequence error: {0}")]
DesignSequenceError(Box<str>),
}
/// A `Result` type alias using [`Primer3Error`].
pub type Result<T> = std::result::Result<T, Primer3Error>;