Confused about how can I handle several "Possible" exceptions in C++ -
i'm going in c++, such creating file. in function creates file, have set several exceptions possible failure. instance if file exists, if disk full, if access allowed, if file creation ends happily etc...now, when want catch them all, confused.
int file_create(std::string file_name) {...} // includes several exceptions @ various points try{ file_create("/var/simple.txt"); } catch(...){ // should here have specific control on exception throw? }
i know ...
catch-all, not if lets deeper investigation of exception thrown?
i compile based on c++011.
you either like:
try { //your code } catch(firstexception &e){} catch(secondexception &e){} ...
or if want catch exceptions defined you, can create custom baseexception
, define others subclasses of one.
Comments
Post a Comment