Is there a way to trap errors and do certain things based on what error is received?

Say, if I get a "Function not defined error" can I, instead of it displaying the error message, have it go to a main function?