From 0e272178d1887b0ef0ccac61876c6f5e30fea22f Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 3 Sep 2024 09:10:14 +0200 Subject: Add more usage of SystemException Prefer this exception for failures involving errno as it gives a better error description. --- common/rfb/SSecurityRSAAES.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/rfb/SSecurityRSAAES.cxx b/common/rfb/SSecurityRSAAES.cxx index 5b3a04d2..92b332d6 100644 --- a/common/rfb/SSecurityRSAAES.cxx +++ b/common/rfb/SSecurityRSAAES.cxx @@ -24,6 +24,7 @@ #error "This source should not be compiled without HAVE_NETTLE defined" #endif +#include #include #include #include @@ -155,7 +156,7 @@ void SSecurityRSAAES::loadPrivateKey() { FILE* file = fopen(keyFile, "rb"); if (!file) - throw Exception("failed to open key file"); + throw rdr::SystemException("failed to open key file", errno); fseek(file, 0, SEEK_END); size_t size = ftell(file); if (size == 0 || size > MaxKeyFileSize) { @@ -166,7 +167,7 @@ void SSecurityRSAAES::loadPrivateKey() std::vector data(size); if (fread(data.data(), 1, data.size(), file) != size) { fclose(file); - throw Exception("failed to read key"); + throw rdr::SystemException("failed to read key", errno); } fclose(file); -- cgit v1.2.3