Throw std::system_error if a file could not be opened in io::file_stream

This commit is contained in:
Nikita Lisitsa 2023-02-12 11:41:02 +03:00
parent 1a06f5071d
commit 0979b55f72

View file

@ -8,7 +8,7 @@ namespace psemek::io
static void throw_fopen [[noreturn]] (std::filesystem::path const & path) static void throw_fopen [[noreturn]] (std::filesystem::path const & path)
{ {
throw std::runtime_error("Failed to open " + path.string() + ": " + std::string(std::strerror(errno))); throw std::system_error(std::error_code{errno, std::system_category()}, "Failed to open " + path.string());
} }
static FILE * safe_fopen(std::filesystem::path const & path, const char * mode) static FILE * safe_fopen(std::filesystem::path const & path, const char * mode)