Source code for cadrumo.application.storage_management.errors
"""Errors raised by the storage-management service.:class:`StorageReclaimRefusedError` is the loud half of the aggregate reclaimguard. It names only the public area and the failed preflight property.See Also: :func:`~cadrumo.application.storage_management.service.reclaim_storage_area` The guarded operation that raises it."""from__future__importannotationsfrom...core.errors.hierarchyimportCadrumoErrorfrom...core.i18n.renderimporttrfrom...core.storage_taxonomyimportStorageArea
[docs]classStorageManagementError(CadrumoError):"""Base for refusals raised while inspecting or reclaiming the storage tree."""
def_area_display(area:StorageArea)->str:"""Return a localized text label while retaining the enum as the API value."""returntr(f"cli.config.storage.values.area.{area.value}",)_REASON_LOCALE_KEYS={"the area contains durable state":"cli.config.storage.errors.reason.durable_state","the taxonomy declares no reclaimable targets":"cli.config.storage.errors.reason.no_reclaimable_targets","a selected target is not root-scoped":"cli.config.storage.errors.reason.not_root_scoped","a selected target has a durable lifecycle":"cli.config.storage.errors.reason.durable_lifecycle","a selected target contains protected declared data":"cli.config.storage.errors.reason.protected_descendant",}
[docs]classStorageReclaimRefusedError(StorageManagementError):"""Refusal to delete an area that cannot pass the derived preflight."""def__init__(self,area:StorageArea,*,entry_count:int,reason:str,)->None:"""Initialize this public contract."""display_reason=tr(_REASON_LOCALE_KEYS[reason],)super().__init__(tr("cli.config.storage.errors.reclaim_area_refused",area=_area_display(area),entries=str(entry_count),reason=display_reason,),context={"area":area.value,"entry_count":str(entry_count),"reason":display_reason,},)self.area=areaself.entry_count=entry_countself._reason=reason@propertydefreason(self)->str:"""Return the stable service reason while text rendering stays localized."""returnself._reason
[docs]classStorageReclaimUnconfirmedError(StorageManagementError):"""Refusal to delete without an explicit confirmation from the caller. The confirmation lives at the service boundary, not only on the CLI flag, so a programmatic caller gets the same guarantee the operator's ``--yes`` buys. """def__init__(self,area:StorageArea,*,entry_count:int)->None:"""Initialize this public contract."""super().__init__(tr("cli.config.storage.errors.reclaim_area_unconfirmed",area=_area_display(area),entries=str(entry_count),),context={"area":area.value,"entry_count":str(entry_count),},)self.area=areaself.entry_count=entry_count