#include <exception>
#include <filesystem>
std::exception &foo(){
try {
if(!std::filesystem::is_directory(std::filesystem::path("sdfsdf"))){
throw std::runtime_error("Error14");
}
}
catch (std::exception &e) {
return e;
}
}
int main(){
foo().what();
// далее обработка принятого сообщения
}
std::filesystem::filesystem_error
In order to ensure that copy functions of filesystem_error are noexcept, typical implementations store an object holding the return value of what() and two std::filesystem::path objects referenced by path1() and path2() respectively in a separately-allocated reference-counted storage.
Currently the MS STL implementation is non-conforming: objects mentioned above are stored directly in the filesystem object, which makes the copy functions not noexcept.