Why do you need to dynamically skip over the code? We use #ifdef to enclose code for some components such as Vision, so if we don’t have the camera connected, that code won’t compile. Isn’t that good enough?
Call me paranoid, but I’m worried about the robustness of the robot. For example, if a wire somehow comes loose during the competition, I’d like to have an error message pop up so we can diagnose it later and continue playing, and still be assured that the robot will continue to function and not accidentally go haywire.
Well then, if you want to do the work. Unfortunately, different components have different ways to report failures. For example, if you are using CANJaguar, WPILib will set error status when an operation failed. So in theory, you can query this status.
So for each component that you wish to write recovery code for, you need to look through the source code of WPILib and find a way to “poll” the health status of the hardware. CANJaguar is an easy one. If you are using PWM for Jaguars, that may be harder. Since PWM is an output only signal. So there is no feedback you can examine. Regarding camera, I haven’t looked through it in too much details, but it seems the camera task also has some sort of status that you may be able to query. Like I said, if you want to do the work, you need to dig into the source code of WPILib.