cast/diagnostic.rs
1//! Stable, machine-readable diagnostic codes emitted by `cast`.
2//!
3//! See [`docs/agents/diagnostics.md`](../../../docs/agents/diagnostics.md)
4//! for the format and registry rules. Most codes re-export per-domain
5//! constants from [`foundry_cli::diagnostic`].
6
7/// Diagnostic codes for read-only RPC commands like `cast call`, `cast tx`.
8pub mod rpc {
9 pub use foundry_cli::diagnostic::network::{RPC_ERROR, RPC_TIMEOUT, RPC_UNAUTHORIZED};
10
11 pub(crate) const ALL: &[&str] = &[RPC_ERROR, RPC_TIMEOUT, RPC_UNAUTHORIZED];
12}
13
14/// All diagnostic codes declared by `cast`.
15pub fn known_codes() -> Vec<&'static str> {
16 let groups: &[&[&str]] = &[rpc::ALL];
17 groups.iter().flat_map(|g| g.iter().copied()).collect()
18}
19
20#[cfg(test)]
21mod tests {
22 use super::*;
23 use foundry_cli::diagnostic::validate;
24
25 #[test]
26 fn every_known_code_validates() {
27 for c in known_codes() {
28 assert!(validate(c).is_ok(), "registered code `{c}` failed validation");
29 }
30 }
31}