[ios.failure] # 31 Input/output library [[input.output]](./#input.output) ## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#ios.failure) ### 31.5.2 Class ios_base [[ios.base]](ios.base#ios.failure) #### 31.5.2.2 Types [[ios.types]](ios.types#ios.failure) #### 31.5.2.2.1 Class ios_base​::​failure [ios.failure] [🔗](#lib:ios_base::failure) namespace std {class ios_base::failure : public system_error {public:explicit failure(const string& msg, const error_code& ec = io_errc::stream); explicit failure(const char* msg, const error_code& ec = io_errc::stream); };} [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L919) An implementation is permitted to define ios_base​::​failure as a synonym for a class with equivalent functionality to class ios_base​::​failure shown in this subclause[.](#1.sentence-1) [*Note [1](#note-1)*: When ios_base​::​failure is a synonym for another type, that type needs to provide a nested type failure to emulate the injected-class-name[.](#1.sentence-2) — *end note*] The classfailure defines the base class for the types of all objects thrown as exceptions, by functions in the iostreams library, to report errors detected during stream buffer operations[.](#1.sentence-3) [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L935) When throwing ios_base​::​failure exceptions, implementations should provide values of ec that identify the specific reason for the failure[.](#2.sentence-1) [*Note [2](#note-2)*: Errors arising from the operating system would typically be reported assystem_category() errors with an error value of the error number reported by the operating system[.](#2.sentence-2) Errors arising from within the stream library would typically be reported as error_code(io_errc​::​stream, iostream_category())[.](#2.sentence-3) — *end note*] [🔗](#lib:ios_base::failure,constructor) `explicit failure(const string& msg, const error_code& ec = io_errc::stream); ` [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L952) *Effects*: Constructs the base class with msg and ec[.](#3.sentence-1) [🔗](#lib:ios_base::failure,constructor_) `explicit failure(const char* msg, const error_code& ec = io_errc::stream); ` [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L963) *Effects*: Constructs the base class with msg and ec[.](#4.sentence-1)