3 core dberror type definition#16
Conversation
…serror, and update thiserror version in workspace
There was a problem hiding this comment.
Pull Request Overview
This PR establishes a unified error handling system for AimDB, supporting all deployment targets from MCU to cloud environments with platform-optimized implementations.
- Implements a comprehensive
DbErrorenum with 14 error variants covering network, capacity, serialization, configuration, resource, and hardware scenarios - Adds conditional compilation support to optimize memory usage (24 bytes for
no_std, 56 bytes forstd) - Provides helper methods for error creation and categorization along with extensive test coverage
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| aimdb-core/src/lib.rs | Replaces placeholder code with proper module structure and API exports |
| aimdb-core/src/error.rs | Implements the complete DbError type system with cross-platform support |
| aimdb-core/Cargo.toml | Adds feature flags and dependencies for error handling |
| Cargo.toml | Updates thiserror dependency to version 2.0.16 |
…te allowed licenses in deny.toml
| /// Data serialization/deserialization errors | ||
| #[cfg_attr(feature = "std", error("Serialization failed: {details}"))] | ||
| SerializationFailed { | ||
| format: u8, // 0=JSON, 1=MessagePack, 2=CBOR, etc. |
There was a problem hiding this comment.
Magic numbers in comments should be defined as constants to improve maintainability and prevent inconsistencies. Consider creating an enum or constants like const FORMAT_JSON: u8 = 0; for these format identifiers.
| /// Resource allocation failures (memory, file handles, etc.) | ||
| #[cfg_attr(feature = "std", error("Resource allocation failed: {details}"))] | ||
| ResourceAllocationFailed { | ||
| resource_type: u8, // 0=Memory, 1=FileHandle, 2=Socket, etc. |
There was a problem hiding this comment.
Similar to the format field, these resource type magic numbers should be defined as constants or an enum to improve code clarity and prevent errors when matching against these values.
Added
aimdb-core/src/error.rswith comprehensive error taxonomies covering Network, Capacity, Serialization, Configuration, Resource, and Hardware scenarios. ([Core DbError Type Definition #3])no_stdmode for MCU/embedded targetsstdmode for edge/cloud environmentsnetwork_timeout(),capacity_exceeded(),hardware_error(), andinternal()constructors. ([Core DbError Type Definition #3])is_network_error(),is_capacity_error(),is_hardware_error()) for semantic error handling. ([Core DbError Type Definition #3])std(default) andno_stdmodes for optimal platform targeting. ([Core DbError Type Definition #3])stdandno_stdenvironments. ([Core DbError Type Definition #3])Changed
Dependencies
stdfeature flag supportno_stdtesting capabilitiesNotes:
stdandno_stdtargets