I just started working on an existing big project. Some of it contains legacy code.
I have been asked to write a component (will run in the same process) which should alert and restart the server in case of a Fatal error or a situation occurred.
For example, when an OutOfMemoryException is thrown I should alert the clients and then restart the server. The problem is, it will be hard and time consuming to search for all the existing Try-catch blocks and then to edit and add new code to their catch blocks. More than that, a new programmer could add a new try-catch block and forget to alert if OutOfMemoryException is catched.
Do you have any idea on how to monitor/listen for OutOfMemoryException (and similar exceptions) without the need to find and edit (and maybe add to) every existing and future Try-catch blocks?
I'm using .Net 4.
Edit:
- OutOfMemoryException is only an example.
- There could be legacy code which catches OutOfMemoryException, prints a message to log then do nothing.