Skip to content

Commit 9a49dec

Browse files
committed
feat(forge): Add FixedChargeLookupFailed error variant for charge lookup failures
1 parent ebf5b0f commit 9a49dec

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/forge/error.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ pub enum Error {
5252
atom_index: usize,
5353
},
5454

55+
/// Fixed charge lookup failed (atom not found in `ffcharge` database).
56+
///
57+
/// This typically indicates a mismatch between protonation state and
58+
/// expected atoms, or an unsupported residue/atom name combination.
59+
#[error("no {category} charge found: residue '{residue}' atom '{atom}' (position: {position})")]
60+
FixedChargeLookupFailed {
61+
/// Category of the fixed charge lookup (protein, nucleic, water, ion).
62+
category: &'static str,
63+
/// Residue name that was being looked up.
64+
residue: String,
65+
/// Atom name that was not found.
66+
atom: String,
67+
/// Position within chain (e.g., "NTerminal", "Middle").
68+
position: String,
69+
},
70+
5571
/// Required force field parameter not found.
5672
///
5773
/// Occurs when an atom type is assigned but no corresponding
@@ -110,6 +126,32 @@ impl Error {
110126
Self::MissingBioMetadata { atom_index }
111127
}
112128

129+
/// Creates a [`FixedChargeLookupFailed`](Error::FixedChargeLookupFailed) error.
130+
///
131+
/// # Arguments
132+
///
133+
/// * `category` — Category of the lookup (protein, nucleic, water, ion)
134+
/// * `residue` — Residue name
135+
/// * `atom` — Atom name
136+
/// * `position` — Position within chain
137+
///
138+
/// # Returns
139+
///
140+
/// A [`FixedChargeLookupFailed`](Error::FixedChargeLookupFailed) error variant.
141+
pub fn fixed_charge_lookup_failed(
142+
category: &'static str,
143+
residue: impl Into<String>,
144+
atom: impl Into<String>,
145+
position: impl Into<String>,
146+
) -> Self {
147+
Self::FixedChargeLookupFailed {
148+
category,
149+
residue: residue.into(),
150+
atom: atom.into(),
151+
position: position.into(),
152+
}
153+
}
154+
113155
/// Creates a [`MissingParameter`](Error::MissingParameter) error.
114156
///
115157
/// # Arguments

0 commit comments

Comments
 (0)