I have a Windows service written in (Visual) C ++ with a very detailed logging function that often helped me find the cause of errors that clients sometimes encounter. Basically, I check every return value and log what happens and where the errors come from.
Ideally, I would like to have the same granularity of visibility in exceptions (for example, an out-of-range array, division by zero, etc.). In other words: I want to know exactly where the exception comes from. For reasons of readability and practicality, I donβt want to wrap all several lines of code in separate try / catch blocks.
What I have today is one common catch that catches everything and logs an error before closing the program. This is good from the point of view of the user - a clean shutdown instead of crashing the application - but bad for me, because I get a general message from the exception (for example, "an array is out of range"), but I have no idea where it comes from.
Wouldn't it be better to remove catch-all and let the program crash instead? I could direct the client to let Windows dump the application (as described here ). With the dump file, WinDbg will precisely point to the position in the code where the exception was thrown.
source share