mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-09-06 12:09:01 +00:00
142f18af1d
PveApiException carried the status, resource, method and API message an ErrorRecord needs, but only about 25 of 194 cmdlets built a record. Every other failing call escaped into PowerShell's default wrapper, so a 403, a 404 and an unreachable server all arrived as ErrorCategory.NotSpecified with error id PveApiException and a null TargetObject. $_.CategoryInfo, -ErrorAction filtering and typed catch blocks had nothing to work with. The classification is a pure function in PSProxmoxVE.Core so it has an offline test path: PveErrorMapper.Describe returns a kind, a stable error id and a target derived from the exception. PveCmdletBase translates the kind to an ErrorCategory and builds the record. The try/catch is a template method rather than 194 hand-written blocks: ProcessRecord is sealed and wraps a new abstract ProcessPveRecord in one catch filtered by PveErrorMapper.IsRecognized, so only the module's own exception types are mapped and every other exception reaches the engine exactly as before, including the ones carrying their own error record. The 192 cmdlets on the base class rename their override; behaviour stays terminating, as an escaped exception already was. Closes #155 Co-authored-by: goodolclint-claude[bot] <323206664+goodolclint-claude[bot]@users.noreply.github.com>