std::filesystem::filesystem_error

From cppreference.com
 
 
 
 
Defined in header <filesystem>
class filesystem_error;
(since C++17)

The class std::filesystem::filesystem_error defines an exception object that is thrown on failure by the throwing overloads of the functions in the filesystem library.

cpp/error/exceptioncpp/error/runtime errorcpp/error/system errorstd-filesystem-filesystem error-inheritance.svg

Inheritance diagram

Member functions

constructs the exception object
(public member function)
replaces the exception object
(public member function)
returns the paths that were involved in the operation that caused the error
(public member function)
returns the explanatory string
(public member function)

Inherited from std::system_error

Member functions

returns error code
(public member function of std::system_error)
[virtual]
returns explanatory string
(virtual public member function of std::system_error)

Inherited from std::runtime_error


Inherited from std::exception

Member functions

[virtual]
destroys the exception object
(virtual public member function of std::exception)
[virtual]
returns an explanatory string
(virtual public member function of std::exception)

Notes

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.

Example