Whatever message this page gives is out now! Go check it out!
try {
Code where exceptions will be caught
}
catch(exceptionType exceptionVariable) {
Code to handle exceptions of type exceptionType
that occur in the try block
}
...
catch(exceptionTypeN exceptionVariableN) {
Code to handle exceptions of type
exceptionTypeN that occur in the try block
}
finally {
Code that will execute whether there is an exception or not.
}<cfscript>
try {
emp = CreateObject("Java", "Employees");
}
catch(any excpt) {
WriteOutput("The application was unable to perform a required operation.<br>
Please try again later.<br>If this problem persists, contact
Customer Service and include the following information:<br>
#excpt.Message#<br>");
}
finally {
writeoutput("<br>Thank you for visiting our web site.<br>come back soon!");
}
</cfscript><cfscript>
try {
// Code that might throw an exception
result = 10 / 0; // This will throw an arithmetic exception
}
catch (expression|application|database e) {
// This block catches arithmetic or divide by zero errors
writeOutput("Error caught: " & e.message);
}
catch (any e) {
// A generic catch block for all other exceptions
writeOutput("Unknown Error: " & e.message);
}
</cfscript>