> Hello, I am wondering if there is a way to differentiate > between CF Errors. > > Like I have a database that has a unique key setup so it will > not allow two records with the same filename field and date > field. If you try the insert you get the below CF error. > > Error Executing Database Query. > [Macromedia][SQLServer JDBC Driver][SQLServer]Violation of > UNIQUE KEY constraint 'IX_CurrentFilesFileNameDate_Unique'. > Cannot insert duplicate key in object 'dbo.CurrentFiles'. > > Now say if the Database is turned off. I will get another > error like datasource cannot be found. > > Is there anyway that in CF I can tell which error is thrown > so I can return different data for each error? > > Right now my code is using <cftry> and <cfcatch>. If the > insert is successful then I return a 1. if <cfcatch> finds > an error I return a 2. What I want to do is if the unique > key is violated I want to return a 1 rather then a 2.
Within your CFCATCH, there will be a CFCATCH structure, which will contain information specific to the exception that was caught. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:257372 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

