Last active
April 11, 2016 16:13
-
-
Save stphnwlkr/db7177faafde5f4c164d842d8e40929e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void function onError(required any exception, required string eventname){ | |
//log error | |
writeLog(file='[LOG FILE NAME]', text='#arguments.exception.message#'); | |
//save error information in a single variable | |
savecontent variable='errortext' { | |
writeOutput("An error occurred: http://#cgi.server_name##cgi.script_name#?#cgi.query_string#<br /> | |
Time: #now().dateFormat('short')# :: #now().timeFormat('short')#<br />"); | |
writeDump(var=arguments.exception, label='Error Log'); | |
writeDump(var=form, label='Form Scope'); | |
writeDump(var=url, label='URL Scope'); | |
writeDump(var=cgi, label='CGI Scope'); | |
} | |
//email the results to your self/admin | |
cfmail(to="[YOUR EMAIL]", from="[YOUR EMAIL]", subject="Error: #arguments.exception.message#",type="html"){ | |
writeOutput(errortext); | |
}; | |
location(url="[REDIRECT TO FRIENDLY ERROR PAGE]", addtoken="false"); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment