Error: HRESULT E_FAIL has been returned from a call to a COM component


I have received this error, but wen I re-ran the project it appears to be working fine. What is the best way to check if this error is being thrown, and to have the project re-launch itself automatically and if it failed again them to have it send me an alert.