diff --git a/include/xrpl/beast/utility/temp_dir.h b/include/xrpl/beast/utility/temp_dir.h index c0bd07881f..36d6bfe0d5 100644 --- a/include/xrpl/beast/utility/temp_dir.h +++ b/include/xrpl/beast/utility/temp_dir.h @@ -17,9 +17,7 @@ namespace beast { checking for existence. */ inline std::filesystem::path -uniqueRandomPath( - std::filesystem::path const& base, - std::size_t maxAttempts = 100) +uniqueRandomPath(std::filesystem::path const& base, std::size_t maxAttempts = 100) { std::random_device rd; for (std::size_t attempt = 0; attempt < maxAttempts; ++attempt) @@ -30,8 +28,10 @@ uniqueRandomPath( std::error_code ec; bool const exists = std::filesystem::exists(candidate, ec); if (ec) + { throw std::runtime_error( "Unable to check path '" + candidate.string() + "': " + ec.message()); + } if (!exists) return candidate; } diff --git a/src/test/app/GRPCServerTLS_test.cpp b/src/test/app/GRPCServerTLS_test.cpp index 7025ed7b54..b5c47d5936 100644 --- a/src/test/app/GRPCServerTLS_test.cpp +++ b/src/test/app/GRPCServerTLS_test.cpp @@ -260,8 +260,8 @@ public: { auto tmpDir = std::filesystem::temp_directory_path(); std::random_device rd; - constexpr std::size_t maxAttempts = 100; - for (std::size_t attempt = 0; attempt < maxAttempts; ++attempt) + constexpr std::size_t kMAX_ATTEMPTS = 100; + for (std::size_t attempt = 0; attempt < kMAX_ATTEMPTS; ++attempt) { std::ostringstream oss; oss << kCERTS_DIR_PREFIX << std::hex << std::setfill('0') << std::setw(8) << rd(); @@ -269,8 +269,10 @@ public: std::error_code ec; bool const exists = std::filesystem::exists(tempDir_, ec); if (ec) + { throw std::runtime_error( "Unable to check path '" + tempDir_.string() + "': " + ec.message()); + } if (!exists) break; tempDir_.clear(); diff --git a/src/xrpld/app/misc/SHAMapStoreImp.cpp b/src/xrpld/app/misc/SHAMapStoreImp.cpp index 7492c39131..10d0fe23e6 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.cpp +++ b/src/xrpld/app/misc/SHAMapStoreImp.cpp @@ -477,8 +477,8 @@ SHAMapStoreImp::makeBackendRotating(std::string path) { std::filesystem::path const p = get(section, "path"); std::random_device rd; - constexpr std::size_t maxAttempts = 100; - for (std::size_t attempt = 0; attempt < maxAttempts; ++attempt) + constexpr std::size_t kMAX_ATTEMPTS = 100; + for (std::size_t attempt = 0; attempt < kMAX_ATTEMPTS; ++attempt) { std::ostringstream oss; oss << std::hex << std::setfill('0') << std::setw(8) << rd() << std::setw(8) << rd(); @@ -487,9 +487,11 @@ SHAMapStoreImp::makeBackendRotating(std::string path) std::error_code existsEc; bool const candidateExists = std::filesystem::exists(candidate, existsEc); if (existsEc) + { Throw( "Unable to check rotating backend path '" + candidate.string() + "': " + existsEc.message()); + } if (!candidateExists) { newPath = candidate;