Try catch exception still showing exception in output

I have put a try\catch arouns some code to make the output nicer to read…but the exception is still shown in the output window even though i have caught it…


try
{            
//exception
}
            catch (Exception)
            {
                Program.loginfo("Could not process GPGSV Data");
            }

Output…
#### Exception System.IndexOutOfRangeException - 0xa9000000 (3) ####
#### Message:
#### zigbox.fezcobra2.GPS.MTK3339::ParseGSVData [IP: 0053] ####
#### zigbox.fezcobra2.GPS.MTK3339::_gpsSP_DataReceived [IP: 0140] ####
#### System.IO.Ports.SerialPort::DataEventHandler [IP: 0012] ####
A first chance exception of type ‘System.IndexOutOfRangeException’ occurred in zigbox.fezcobra2.exe
Could not process GPGSV Data

Catching an exception and output of the exception’s information are two different things in general.

@ anthonys - What you are seeing here is a First Chance Exception. When a debugger is attached to the application the debugger is notified of all exceptions and has the first chance at dealing with the exception, the debugger then chooses to either break into the code, pass the exception on so that your code can handle it. In this case the debugger has opted to display the exception detail before moving one.

If you do not handle the exception then the debugger will get a second chance exception which will then stop the application with an unhandled exception.

1 Like

thanks Guys again…

@ anthonys - It is a pleasure

1 Like