cpp/io/basic ios/exceptions
From cppreference.com
std::ios_base::iostate exceptions() const; |
||
void exceptions(std::ios_base::iostate except); |
||
[edit] Parameters
except | - | exception mask |
[edit] Example
#include <iostream> #include <fstream> int main() { int ivalue; try { std::ifstream in("in.txt"); in.exceptions(std::ifstream::failbit); in >> ivalue; } catch (std::ios_base::failure &fail) { // handle exception here } }