How do I input error handling within the programming [if, else, etc.] controllers?

Would appreciate your knowledge of how this could be done, within an example.

Thanks in advance,

Panarchy