PCEPR (Platform Configuration Error Registry) is a Rust library for standardizing, registering, and managing platform configuration errors across systems. It provides a unified way to handle and reference error codes with their associated descriptions.
The primary motivation behind PCEPR is to address several critical challenges in platform error management:
-
Standardization: Many systems lack a consistent approach to error codes, leading to confusion, duplications, and inconsistencies across teams and components. PCEPR establishes a central registry that enforces uniqueness and proper documentation.
-
Error Type Segmentation: PCEPR distinguishes between standard (well-established) errors and experimental errors, allowing teams to innovate without polluting the main error namespace.
-
Centralized Documentation: Instead of having error definitions scattered across codebases, PCEPR provides a single source of truth for error codes, their meanings, and proper handling approaches.
-
Configuration-Driven: Error definitions can be loaded from YAML configuration files, enabling version control of error codes and making it easier to maintain backward compatibility.
-
Programmatic Access: The registry can be accessed programmatically, allowing systems to retrieve error information at runtime for better error reporting and handling.
- ErrorType/ErrorValue: The fundamental units representing error codes
- StandardRegistry: Contains officially approved and stable error definitions
- ExperimentalRegistry: Contains provisional errors that may eventually be promoted to standard
- Configuration Loader: Loads error definitions from YAML files
use pcepr::{StandardRegistry, ExperimentalRegistry, ErrorType, ErrorValue};
// Create registries
let mut std_reg = StandardRegistry::new();
let mut exp_reg = ExperimentalRegistry::new();
// Load error definitions from config file
pcepr::config::loader::load_registry_from_file("errors.yaml", &mut std_reg, &mut exp_reg)?;
// Now you can work with the registered errors
standard:
- error_type: 1
error_value: 1
description: "Resource not found"
- error_type: 1
error_value: 2
description: "Resource access denied"
experimental:
- error_type: 200
error_value: 1
description: "Experimental feature unavailable"
[Add appropriate license here]