Although I use C ++ 11, this question is related to boost as I handle errors from boost::file_system.
In the following situation:
try {
path p = canonical(p2);
} catch (filesystem_error& e) {
if (e is the no_such_file_or_directory exception)
custom_message(e);
}
}
If I print the error value when the desired exception is thrown (no_such_file_or_directory):
} catch (filesystem_error& e) {
cout << "Value: " << e.code().value() << endl;
}
I get the value 2. This is the same meaning e.code().default_error_condition().value().
My questions are: can different error conditions from different error categories have the same meanings? I mean, do I need to check both error categories and error values to make sure I get a specific error? Then what is the cleanest way to do this?
source
share