4.9 KiB
[fs.class.filesystem.error]
31 Input/output library [input.output]
31.12 File systems [filesystems]
31.12.7 Class filesystem_error [fs.class.filesystem.error]
31.12.7.1 General [fs.class.filesystem.error.general]
namespace std::filesystem {class filesystem_error : public system_error {public: filesystem_error(const string& what_arg, error_code ec); filesystem_error(const string& what_arg, const path& p1, error_code ec); filesystem_error(const string& what_arg, const path& p1, const path& p2, error_code ec); const path& path1() const noexcept; const path& path2() const noexcept; const char* what() const noexcept override; };}
The class filesystem_error defines the type of objects thrown as exceptions to report file system errors from functions described in subclause [filesystems].
31.12.7.2 Members [fs.filesystem.error.members]
Constructors are provided that store zero, one, or two paths associated with an error.
filesystem_error(const string& what_arg, error_code ec);
Postconditions:
code() == ec is true,
path1().empty() is true,
path2().empty() is true, and
string_view(what()).find(what_arg.c_str()) != string_view::npos is true.
filesystem_error(const string& what_arg, const path& p1, error_code ec);
Postconditions:
code() == ec is true,
path1() returns a reference to the stored copy of p1,
path2().empty() is true, and
string_view(what()).find(what_arg.c_str()) != string_view::npos is true.
filesystem_error(const string& what_arg, const path& p1, const path& p2, error_code ec);
Postconditions:
code() == ec,
path1() returns a reference to the stored copy of p1,
path2() returns a reference to the stored copy of p2, and
string_view(what()).find(what_arg.c_str()) != string_view::npos.
const path& path1() const noexcept;
Returns: A reference to the copy of p1 stored by the constructor, or, if none, an empty path.
const path& path2() const noexcept;
Returns: A reference to the copy of p2 stored by the constructor, or, if none, an empty path.
const char* what() const noexcept override;
Returns: An ntbs that incorporates the what_arg argument supplied to the constructor.
The exact format is unspecified.
Implementations should include the system_error::what() string and the pathnames of path1 and path2 in the native format in the returned string.