In case of an error, the WebGUI expects the SMART data API endpoint to
return a health value, but it will return an error message directly. To
make this more user friendly, mask the error in the API handler.

Signed-off-by: Daniel Kral <d.k...@proxmox.com>
---
This could also have been intentional as the error message is passed to
the CLI and API response correctly, which is why it is a RFC.

 src/PVE/API2/Disks.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/Disks.pm b/src/PVE/API2/Disks.pm
index 408bdbe..fe8d08e 100644
--- a/src/PVE/API2/Disks.pm
+++ b/src/PVE/API2/Disks.pm
@@ -216,7 +216,9 @@ __PACKAGE__->register_method ({
 
        my $disk = PVE::Diskmanage::verify_blockdev_path($param->{disk});
 
-       my $result = PVE::Diskmanage::get_smart_data($disk, 
$param->{healthonly});
+       my $result = eval {
+           PVE::Diskmanage::get_smart_data($disk, $param->{healthonly})
+       };
 
        $result->{health} = 'UNKNOWN' if !defined $result->{health};
        $result = { health => $result->{health} } if $param->{healthonly};
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to