diff --git a/src/PSProxmoxVE.Core/Services/VmService.cs b/src/PSProxmoxVE.Core/Services/VmService.cs index 412e1ab..2f4aae0 100644 --- a/src/PSProxmoxVE.Core/Services/VmService.cs +++ b/src/PSProxmoxVE.Core/Services/VmService.cs @@ -550,8 +550,9 @@ namespace PSProxmoxVE.Core.Services client.PostAsync($"nodes/{Uri.EscapeDataString(node)}/qemu/{vmid}/agent/ping").GetAwaiter().GetResult(); return true; } - catch (Exception ex) when (ex is not OutOfMemoryException and not StackOverflowException) + catch (PSProxmoxVE.Core.Exceptions.PveApiException) { + // Treat API-level failures for this endpoint as "guest agent not responding". return false; } finally diff --git a/src/PSProxmoxVE/Cmdlets/Vms/ImportPveOvaCmdlet.cs b/src/PSProxmoxVE/Cmdlets/Vms/ImportPveOvaCmdlet.cs index dd00cee..1766a9c 100644 --- a/src/PSProxmoxVE/Cmdlets/Vms/ImportPveOvaCmdlet.cs +++ b/src/PSProxmoxVE/Cmdlets/Vms/ImportPveOvaCmdlet.cs @@ -2,8 +2,10 @@ using System; using System.Collections.Generic; using System.IO; using System.Management.Automation; +using System.Net; using Newtonsoft.Json.Linq; using PSProxmoxVE.Core.Client; +using PSProxmoxVE.Core.Exceptions; using PSProxmoxVE.Core.Models.Vms; using PSProxmoxVE.Core.Services; @@ -274,9 +276,9 @@ namespace PSProxmoxVE.Cmdlets.Vms var vm = vmService.GetVm(session, Node, vmId); WriteObject(vm); } - catch (Exception ex) when (ex is not OutOfMemoryException and not StackOverflowException) + catch (PveApiException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { - // If the VM isn't queryable yet (e.g. disk import still running), return basic info + // VM not yet queryable (e.g. disk import still in progress); return basic info WriteVerbose($"VM retrieval failed, returning basic info: {ex.Message}"); WriteObject(new PveVm {