3 ms·
My guess would be add assertions everywhere instead of throwing exceptions.
by wsc981 4y ago
My guess would be add assertions everywhere instead of throwing exceptions.
- Karellen 4y agoWhy not throw exceptions, and just never use try/catch? That way, all exceptions are uncaught and should terminate the program, in a way that takes advantage of the programming language's native error reporting facilities.
- hsn915 4y agoassertion failures terminate the program immediately. exceptions usually trigger cleanup code. If your cleanup code is mostly closing files and clearing memory, then it's useless because the OS will do that for your crashed program anyway.
- roeles 4y agoI don't know of a way to test this behavior (I mainly code C++ and unit test with Google Test). One could spawn a process and capture the output and return value, but that sounds a bit heavy for just testing if your error handling still works as intended.