Are there any means of handling errors globally? Also, how do I determine what kind of error the error is.

I would like to have my application detect an error, then message the user that there is an error, save the users work, then close the application.

Handling the errors globally would make this much simpler and efficient. Thanks fallas.