3 ms·
Entire books, I'm sure, have been written about the pro and cons of exceptions for error handling. Yes, I called it "idiomatic C++" before, but reasonable peop
by knorker 4y ago
Entire books, I'm sure, have been written about the pro and cons of exceptions for error handling.
Yes, I called it "idiomatic C++" before, but reasonable people disagree about the best option.
Smarter people than me have written good things in the E section of the C++ Core Guidelines. The people involved have overlap with the C++ standards committee:
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#S-errors http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#...
At least if you use exceptions for errors C++ doesn't need "finally", because it has working RAII, unlike Java.
- grishka 4y agoIn modern Java, and by modern I mean 8 and newer, you no longer need "finally", there's "try with resources" instead that would close everything upon leaving the try block: try(FileInputStream in=new FileInputStream(file)){ // do something with the file data }catch(IOException x){ x.printStackTrace(); } It's been a very long time since I last wrote "something.close()".