Log in

View Full Version : Exception Handling


PLAIDProgrammer
17-02-2013, 01:37
Although we would not like to be having exceptions at this stage in code, it happens. I was wondering weather other programmers catch exceptions or let them stop the code? Any help will really make my teams life much easier.
Lenny

gixxy
17-02-2013, 02:05
I believe in catching errors and handling them rather than letting them crash code. Especially if you know what could cause them to happen.


This year a major example is our RaspberryPi, which we are using to process camera images. We them pipe the data back to the cRIO via TCP Socket. There will be times where something goes wrong and I will get an IOException, and I would rather have it handled gracefully and keep the robot running rather than it crash.

Cel Skeggs
18-02-2013, 15:35
In our code base, we catch certain kinds of errors - anything that we know could be thrown (for example IOException or NumberFormatException) we will catch.
Most of the time, we don't try to catch exceptions if we don't know they'll be thrown - it's not useful to us to try to catch ArrayIndexOfOfBoundsException or NullPointerException, because generally they imply that there's a bug in our code that should be fixed.