From 0979b55f72b05c12dc9ec912506ad0b12c1bcae8 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sun, 12 Feb 2023 11:41:02 +0300 Subject: [PATCH] Throw std::system_error if a file could not be opened in io::file_stream --- libs/io/source/file_stream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/io/source/file_stream.cpp b/libs/io/source/file_stream.cpp index 50c809cb..56b3eb0e 100644 --- a/libs/io/source/file_stream.cpp +++ b/libs/io/source/file_stream.cpp @@ -8,7 +8,7 @@ namespace psemek::io 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)