[fs.class.filesystem.error]

# 31 Input/output library [[input.output]](./#input.output)

## 31.12 File systems [[filesystems]](filesystems#fs.class.filesystem.error)

### 31.12.7 Class filesystem_error [fs.class.filesystem.error]

#### [31.12.7.1](#general) General [[fs.class.filesystem.error.general]](fs.class.filesystem.error.general)

[ð](#lib:filesystem_error)

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; };}

[1](#general-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15591)

The class filesystem_error defines the type of
objects thrown as exceptions to report file system errors from functions described in
subclause [[filesystems]](filesystems "31.12 File systems")[.](#general-1.sentence-1)

#### [31.12.7.2](#fs.filesystem.error.members) Members [[fs.filesystem.error.members]](fs.filesystem.error.members)

[1](#fs.filesystem.error.members-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15598)

Constructors are provided that store zero, one, or two paths associated with
an error[.](#fs.filesystem.error.members-1.sentence-1)

[ð](#lib:filesystem_error,constructor)

`filesystem_error(const string& what_arg, error_code ec);
`

[2](#fs.filesystem.error.members-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15608)

*Postconditions*: 

- [(2.1)](#fs.filesystem.error.members-2.1)

code() == ec is true,

- [(2.2)](#fs.filesystem.error.members-2.2)

path1().empty() is true,

- [(2.3)](#fs.filesystem.error.members-2.3)

path2().empty() is true, and

- [(2.4)](#fs.filesystem.error.members-2.4)

string_view(what()).find(what_arg.c_str()) != string_view​::​npos is true[.](#fs.filesystem.error.members-2.sentence-1)

[ð](#lib:filesystem_error,constructor_)

`filesystem_error(const string& what_arg, const path& p1, error_code ec);
`

[3](#fs.filesystem.error.members-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15624)

*Postconditions*: 

- [(3.1)](#fs.filesystem.error.members-3.1)

code() == ec is true,

- [(3.2)](#fs.filesystem.error.members-3.2)

path1() returns a reference to the stored copy of p1,

- [(3.3)](#fs.filesystem.error.members-3.3)

path2().empty() is true, and

- [(3.4)](#fs.filesystem.error.members-3.4)

string_view(what()).find(what_arg.c_str()) != string_view​::​npos is true[.](#fs.filesystem.error.members-3.sentence-1)

[ð](#lib:filesystem_error,constructor__)

`filesystem_error(const string& what_arg, const path& p1, const path& p2, error_code ec);
`

[4](#fs.filesystem.error.members-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15640)

*Postconditions*: 

- [(4.1)](#fs.filesystem.error.members-4.1)

code() == ec,

- [(4.2)](#fs.filesystem.error.members-4.2)

path1() returns a reference to the stored copy of p1,

- [(4.3)](#fs.filesystem.error.members-4.3)

path2() returns a reference to the stored copy of p2, and

- [(4.4)](#fs.filesystem.error.members-4.4)

string_view(what()).find(what_arg.c_str()) != string_view​::​npos[.](#fs.filesystem.error.members-4.sentence-1)

[ð](#lib:path1,filesystem_error)

`const path& path1() const noexcept;
`

[5](#fs.filesystem.error.members-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15656)

*Returns*: A reference to the copy of p1 stored by the
 constructor, or, if none, an empty path[.](#fs.filesystem.error.members-5.sentence-1)

[ð](#lib:path2,filesystem_error)

`const path& path2() const noexcept;
`

[6](#fs.filesystem.error.members-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15668)

*Returns*: A reference to the copy of p2 stored by the
 constructor, or, if none, an empty path[.](#fs.filesystem.error.members-6.sentence-1)

[ð](#lib:what,filesystem_error)

`const char* what() const noexcept override;
`

[7](#fs.filesystem.error.members-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15680)

*Returns*: An ntbs that incorporates
 the what_arg argument supplied to the constructor[.](#fs.filesystem.error.members-7.sentence-1)

The exact format is unspecified[.](#fs.filesystem.error.members-7.sentence-2)

Implementations should include
 the system_error​::​what() string and
 the pathnames of path1 and path2 in the native format in the returned string[.](#fs.filesystem.error.members-7.sentence-3)
