3 ms·
> In C++ I find it quite infuriating that try{} opens up a new lexical scope That’s an interesting point. I’ve never considered that because I haven’t worked w
by senkora 3y ago
> In C++ I find it quite infuriating that try{} opens up a new lexical scope
That’s an interesting point. I’ve never considered that because I haven’t worked with classes that regularly throw in their constructors.
What situation do you have where 1) you are constructing classes that regularly throw in their constructors and 2) this is a recoverable error that 3) should be handled at the point where the class is constructed instead of some outer point?
- grumbel 3y agoCode like: QImage image("filename.png"); is pretty common. Qt solves this by not throwing an exception and using a Null image check: bool QImage::isNull() const but that throws all the extra information that an Exception could provide away.