molframe_core/io/
structure_batch_diagnostics.rs1use super::StructureBatchError;
4use crate::diagnostic::{Code, Diagnostic};
5
6impl From<&StructureBatchError> for Diagnostic {
7 fn from(error: &StructureBatchError) -> Self {
10 let code = match error {
11 StructureBatchError::Diagnostic(inner) => return inner.clone(),
12 StructureBatchError::DemandTooSmall { .. } => Code::E5101,
13 StructureBatchError::RecordExceedsBudget { .. } | StructureBatchError::Memory(_) => {
14 Code::E7001
15 }
16 StructureBatchError::Identity(_) | StructureBatchError::DictionaryFull => Code::E1903,
17 };
18 Self::new(code).with_message(error.to_string())
19 }
20}
21
22impl From<StructureBatchError> for Diagnostic {
23 fn from(error: StructureBatchError) -> Self {
24 Self::from(&error)
25 }
26}
27
28#[cfg(test)]
29#[path = "structure_batch_diagnostics_tests.rs"]
30mod tests;