Context Docs: Exception Handling
The Context interface provides three API methods specific to exception handling;
As the names of the methods imply, you can register exception handlers with the parent context and at any point ask the context if it contains a handler for a specific exception type as well as retrieve the instance of the handler.
Handling an exception is fairly straight-forward; if an exception is thrown at anytime during the execution of a plugin behavior, the context will attempt to map the exception "type" with a registered handler. If it can map the exception "type" with a handler, then the context will invoke the correct method on the handler passing in the actual exception stack. This way you can deal with context exceptions elegantly if needed.
ExceptionHandler interface
You can register your own custom ExceptionHandler with a parent context at any time, as long as your component implements the ExceptionHandler interface;
getType() must return the "type" (as a string) of exception that the handler is intended to service. This value should correspond with any possible "type" attribute values of the <cfthrow /> tag. "Any" is a catch-all and any exception thrown, regardless of it's declared type, will map to your handler if the getType() method returns the value "Any".
getClassName() must return a fully-qualified dot-notation path to your handler component, e.g.; com.mydomain.MyExceptionHandler.
getMethodName() must return the name of the method declared on your class that is intended to handle the resulting exception. This method must account for the exception in its signature as such;
getViewTemplate() does not have to return a value - it can return null, but only if your exception handler is not intended to handle an exception gracefully within an HTTPContext. You can optionally return the path to an actual *.cfm template with this method if you would like the HTTPContext to "finalize" the exception by rendering a type of "OOPS" page. If null is returned from this value, then although the handler process is executed, the exception itself is re-thrown.
Again, Order Matters
Only one exception handler will be asked to service an exception. This means that if more than one handler has been registered to service the same exception type, than the first one found will be the one that is used.
SimpleMVCPlugin
When working with an HTTPContext that contains the SimpleMVCPlugin plugin, you can declare exception handlers directly in the mvc configuration file;