Skip to main content

powerio_matrix/
diagnostics.rs

1//! The codes this crate emits.
2//!
3//! The record, the code grammar, and the severity ladder live in
4//! `powerio-core`; the entries here are the matrix, sensitivity, and dataset
5//! side of the workspace registry. A hub failure that arrives through
6//! [`crate::Error::Transmission`] keeps the hub's own code.
7
8pub use powerio_core::{
9    Diagnostic, DiagnosticInfo, DiagnosticSeverity, check_registry, render_diagnostic,
10    render_diagnostics,
11};
12
13pub mod codes {
14    powerio_core::diagnostic_codes! {
15        // BUILD: assembling a derived object from a network that already parsed.
16        BUILD_MATRIX_SHAPE_MISMATCH = "BUILD.MATRIX.SHAPE_MISMATCH", Error,
17            "an operand's length does not match the matrix it is used with", category = Data;
18        BUILD_OPF_OBJECTIVE_UNSUPPORTED = "BUILD.OPF.OBJECTIVE_UNSUPPORTED", Error,
19            "the OPF preparation cannot compile the instance objective", category = Data;
20        BUILD_OPF_CONSTRAINT_IDENTITY_UNKNOWN = "BUILD.OPF.CONSTRAINT_IDENTITY_UNKNOWN", Error,
21            "an active constraint selection names no element in its family", category = Data;
22        BUILD_OPF_ELEMENT_IDENTITY_DUPLICATE = "BUILD.OPF.ELEMENT_IDENTITY_DUPLICATE", Error,
23            "an OPF element family does not have unique stable identities", category = Data;
24        BUILD_OPF_NODAL_COST_UNSUPPORTED = "BUILD.OPF.NODAL_COST_UNSUPPORTED", Error,
25            "a nodal quadratic projection cannot carry the prepared generator cost", category = Request;
26        BUILD_AC_PF_SPECIFICATION_UNSUPPORTED = "BUILD.AC_PF.SPECIFICATION_UNSUPPORTED", Error,
27            "the AC power flow preparation does not support a bus specification", category = Data;
28        BUILD_MC_OPF_INVALID = "BUILD.MULTI.OPF_INVALID", Error,
29            "invalid multiconductor OPF coefficients, mappings or topology", category = Data;
30        BUILD_MULTI_PHYSICS_UNSUPPORTED = "BUILD.MULTI.PHYSICS_UNSUPPORTED", Error,
31            "the requested multiconductor calculation requires unsupported equipment equations", category = Data;
32        BUILD_MC_OPF_LOAD_LAW_PROJECTED = "BUILD.MULTI.LOAD_LAW_PROJECTED", Warning,
33            "a voltage-bounded load law was projected to its nominal law at the caller's request";
34        BUILD_MULTI_UNSUPPORTED_STAMP = "BUILD.MULTI.UNSUPPORTED_STAMP", Warning,
35            "an element has no exact multiconductor admittance or ideal stamp and was omitted loudly";
36        BUILD_LINDIST3FLOW_COEFFICIENT_INVALID = "BUILD.MULTI.LINDIST3FLOW_COEFFICIENT_INVALID", Error,
37            "a LinDist3Flow affine coefficient operand is invalid", category = Data;
38        BUILD_SENSITIVITY_SINGULAR = "BUILD.SENSITIVITY.SINGULAR", Error,
39            "the reference grounded Laplacian is singular", category = Data;
40        BUILD_SENSITIVITY_INVALID_OPTION = "BUILD.SENSITIVITY.INVALID_OPTION", Error,
41            "a DC sensitivity option is outside the range it is defined on", category = Data;
42        BUILD_STATED_STATE_LCC_MODEL_UNAVAILABLE = "BUILD.STATED_STATE.LCC_MODEL_UNAVAILABLE", Warning,
43            "an LCC converter record reaches no bridge operating point at the stored voltages; the line's stated reactive powers were kept";
44        /// Retired in 0.11.0: the conjugate gradient solver this reported on
45        /// was replaced by a sparse direct factorization, which either
46        /// succeeds or reports singularity.
47        BUILD_SENSITIVITY_NO_CONVERGENCE = "BUILD.SENSITIVITY.NO_CONVERGENCE", Error,
48            "the iterative DC sensitivity solve ran out of iterations", retired = "0.11.0";
49        BUILD_GRIDFM_EMPTY_BATCH = "BUILD.GRIDFM.EMPTY_BATCH", Error,
50            "a gridfm scenario batch holds no snapshot", category = Data;
51        BUILD_GRIDFM_SCENARIO_ID_OVERFLOW = "BUILD.GRIDFM.SCENARIO_ID_OVERFLOW", Error,
52            "numbering a gridfm snapshot overflows the scenario id", category = Data;
53        BUILD_GRIDFM_NORMALIZED_SNAPSHOT = "BUILD.GRIDFM.NORMALIZED_SNAPSHOT", Error,
54            "a gridfm snapshot is normalized and the export expects raw units", category = Data;
55        BUILD_GRIDFM_NOT_A_NUMBER = "BUILD.GRIDFM.NOT_A_NUMBER", Error,
56            "a gridfm snapshot field is not finite", category = Data;
57        BUILD_GRIDFM_SCENARIO_SHAPE_MISMATCH = "BUILD.GRIDFM.SCENARIO_SHAPE_MISMATCH", Error,
58            "a gridfm snapshot does not share the batch's base element set", category = Data;
59
60        // READ and EMIT: this crate's own file side.
61        READ_MATRIX_IO_FAILED = "READ.MATRIX.IO_FAILED", Error,
62            "a matrix or dataset file could not be read", category = Io;
63        EMIT_MTX_FAILED = "EMIT.MTX.FAILED", Error,
64            "a matrix-market write failed", category = Output;
65        EMIT_PARQUET_FAILED = "EMIT.PARQUET.FAILED", Error,
66            "a gridfm Parquet write failed", category = Output;
67        EMIT_GRIDFM_FIELD_DROPPED = "EMIT.GRIDFM.FIELD_DROPPED", Warning,
68            "a source field has no GridFM table column";
69        EMIT_GRIDFM_VALUE_COLLAPSED = "EMIT.GRIDFM.VALUE_COLLAPSED", Warning,
70            "several source records were folded into one GridFM row";
71        EMIT_GRIDFM_VALUE_SUBSTITUTED = "EMIT.GRIDFM.VALUE_SUBSTITUTED", Warning,
72            "a source value was replaced by GridFM's indexed or fixed representation";
73        EMIT_GRIDFM_VALUE_DEFAULTED = "EMIT.GRIDFM.VALUE_DEFAULTED", Warning,
74            "a required GridFM value was derived because the source did not state it";
75
76    }
77}
78
79/// Every code this crate declares.
80#[must_use]
81pub fn registry() -> Vec<&'static DiagnosticInfo> {
82    codes::ALL.to_vec()
83}
84
85#[cfg(test)]
86mod tests {
87    use super::*;
88
89    #[test]
90    fn the_registry_is_sound() {
91        let problems = check_registry(registry());
92        assert!(problems.is_empty(), "{problems:#?}");
93    }
94}