nemo_flow_adaptive/acg/error.rs
1// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Error types for the Adaptive Cache Governor (ACG) crate.
5//!
6//! All fallible operations in the Adaptive Cache Governor (ACG) system return
7//! [`Result<T>`], which uses [`AcgError`] as the error type.
8
9use thiserror::Error;
10
11/// The error type for all Adaptive Cache Governor (ACG) operations.
12#[derive(Debug, Error)]
13pub enum AcgError {
14 /// An intent validation failed.
15 #[error("invalid intent: {0}")]
16 InvalidIntent(String),
17
18 /// A serialization or deserialization error.
19 #[error("serialization error: {0}")]
20 Serialization(#[from] serde_json::Error),
21
22 /// An internal error.
23 #[error("internal error: {0}")]
24 Internal(String),
25
26 /// A plugin with this ID is already registered.
27 #[error("plugin already registered: {0}")]
28 PluginAlreadyRegistered(String),
29
30 /// No plugin found with the given ID.
31 #[error("plugin not found: {0}")]
32 PluginNotFound(String),
33
34 /// Plugin translation failed.
35 #[error("plugin translation error: {0}")]
36 TranslationFailed(String),
37
38 /// IR construction failed due to invalid input.
39 #[error("IR construction error: {0}")]
40 IrConstructionError(String),
41}
42
43/// A specialized [`Result`](std::result::Result) type for ACG operations.
44pub type Result<T> = std::result::Result<T, AcgError>;
45
46#[cfg(test)]
47#[path = "../../tests/unit/acg/error_tests.rs"]
48mod tests;