Of course, we all write perfect code, first time through. At least, that’s what we wake up every morning hoping to accomplish–a hope that is normally dashed within the first 15 minutes of coding.
Any of the Apex development environments parse your code before allowing the code to be saved. This enforcement means that your code is syntactically correct, but there is no guarantee that the code will not encounter error conditions at run-time.
When an Apex trigger or class encounters an error at runtime, the Force Platform environment throws an exception and terminates the execution of the code immediately. You can include code that allows you to handle exceptions more gracefully with try/catch syntax.
The form for try/catch ...