Interceptors
~/.CommandBox/cfml/modules
+-- myModule/
|-- ModuleConfig.cfc
+-- interceptors/
+-- MyInterceptor.cfcCreating An Interceptor
component {
// This runs after every command execution
function postCommand( interceptData ) {
// Overwrite the results with an upper case version of itself
interceptData.results = ucase( interceptData.results );
}
// This runs after every error
function onException( interceptData ) {
// Write the last exception to a file
fileWrite( '/commandbox-home/logs/lastError.txt', serializeJSON( interceptData.exception ) );
}
}Registering An Interceptor
Last updated
Was this helpful?