Well, there are a few different types of errors:
1. Syntactic: User enters a letter when a number is required.
2. Semantic: User enters a value that doesn't make sense in relation to
another value
3. System: The database server could not be contacted.

In most cases, I use a self-posting form.  That way, I can easily
re-fill the form fields in case an error occurs.

For syntactic errors, most likely, you will just re-load the form and
display an error.

Semantic errors are probably handled the same way, in general.

If there is a problem with the database connection, or any other
"critical" problem, you may as well just display an error page, then
send an email to the administrator.

If you haven't already, you should look through the CFC mailing list
archives a cfczone.org.  There are oodles and scads of posts regarding
just this topic.

M!ke 

-----Original Message-----
From: Cameron Johnson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 24, 2005 4:16 PM
To: CF-Talk
Subject: CFC forms and error handling

Hi, all.

I've checked the forums for similar posts, but I've not found a clear
answer. So, this may be a bit of a repeat.

I've got a simple CFC consisting of four files: form.cfm,
formAction.cfm, testCFC.cfc, show.cfm.

In formAction.cfm, I wrap the <cfinvoke> in a <cftry> to catch any
database errors:

<cftry>
        <cfinvoke component="testCFC" method="insertRecord"
returnvariable="newRecordID" argumentcollection="#form#"></cfinvoke>
        
        <cflocation url="show.cfm?id=#newRecordID#" addtoken="No" />

        <cfcatch type="Database">
                ERROR!
        </cfcatch>
</cftry>        

I purposely cause an error by trying to insert a string value into an
integer field. 

Question: once I catch the error, how do I get the user back to the form
and populate the form fields with what the user has already typed in?

One post recommended putting all the form fields in the session scope,
then populating the form with session variables. But, that seems very
cumbersome. 

Thanks for the help,

Cameron

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:216292
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to