diff --git a/tests/test_util/executable_path.cpp b/tests/test_util/executable_path.cpp index fdd87ec8..1477214a 100644 --- a/tests/test_util/executable_path.cpp +++ b/tests/test_util/executable_path.cpp @@ -23,11 +23,11 @@ #include "executable_path.hpp" #include +#include #include +#include #if defined(_WIN32) - #include - #include "util/platform.hpp" namespace test_util { @@ -37,15 +37,14 @@ std::string get_executable_path() { if (size) { return std::string(buffer.data(), size); } - throw std::runtime_error("Could not get executable path"); + throw std::system_error(std::make_error_code(std::errc::no_such_file_or_directory), + "Could not get executable path"); } } // namespace test_util #elif defined(__APPLE__) #include - #include - namespace test_util { std::string get_executable_path() { std::array buffer{}; @@ -53,15 +52,14 @@ std::string get_executable_path() { if (::_NSGetExecutablePath(buffer.data(), &size) == 0) { return std::string(buffer.data()); } - throw std::runtime_error("Could not get executable path"); + throw std::system_error(std::make_error_code(std::errc::no_such_file_or_directory), + "Could not get executable path"); } } // namespace test_util #elif defined(__linux__) #include - #include - namespace test_util { std::string get_executable_path() { std::array buffer{}; @@ -69,7 +67,8 @@ std::string get_executable_path() { if (size != -1) { return std::string(buffer.data(), size); } - throw std::runtime_error("Could not get executable path"); + throw std::system_error(std::make_error_code(std::errc::no_such_file_or_directory), + "Could not get executable path"); } } // namespace test_util