Skip to main content

qualia_core_db/q42/app_registry/
error.rs

1//! Errors for the installed-app registry (WD-02).
2
3use std::fmt;
4
5use crate::q42::app_manifest::AppManifestError;
6
7/// Registry-level failures that reject registration (no slot written).
8#[derive(Debug, Clone, PartialEq, Eq)]
9pub enum AppRegistryError {
10    /// Fixed slot budget exhausted.
11    RegistryFull,
12    /// Bytes could not be decoded and no recoverable identity for quarantine.
13    RejectedMalformed,
14    /// Empty or whitespace-only app id after recovery / registration.
15    MissingAppId,
16    /// Underlying manifest codec / validation error surfaced when rejecting.
17    Manifest(AppManifestError),
18}
19
20impl fmt::Display for AppRegistryError {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        match self {
23            Self::RegistryFull => write!(f, "installed-app registry is full"),
24            Self::RejectedMalformed => {
25                write!(f, "malformed package rejected (identity not recoverable)")
26            }
27            Self::MissingAppId => write!(f, "app id is required"),
28            Self::Manifest(e) => write!(f, "manifest error: {e}"),
29        }
30    }
31}
32
33impl std::error::Error for AppRegistryError {
34    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
35        match self {
36            Self::Manifest(e) => Some(e),
37            _ => None,
38        }
39    }
40}
41
42impl From<AppManifestError> for AppRegistryError {
43    fn from(value: AppManifestError) -> Self {
44        Self::Manifest(value)
45    }
46}