Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFTRY tag 1

Status
Not open for further replies.

jhall01

Programmer
Jul 3, 2003
328
US
Ok here is my situation!

Our companies web host does not allow for the use of cftry tag. I am new to cold fusion and have been given a password changing page that uses cftry blocks. I didn't create the page and is setup kinda funky whoever wrote this.

I need to find a way to do some exception handling for this change password stuff and not use the cftry tag. I will give as much code here as possible but some is proprietary.

<cftry>
<cfldap stuff...... server, uname, ou, o, password, attribute, action=&quot;Modify, dn>
<cfoutput> Password Changed</cfoutput>
<cfcatch type=&quot;any&quot;>
<cfif REFindNoCase(&quot;invalid credentials&quot;,#cfcatch.detail#) GT 0>
<cfoutput>old password invalid</cfoutput>

<cfelseif REF...(&quot;no such object&quot;,...>
<cfoutput> the ID you entered &quot;# userID #&quot;, does not exist</cfoutput>
<cfelse>
<cfoutput>#cfcatch.detail#</cfoutput>
</cfif>
</cfcatch>
</cftry>

I cannot use the cftry and cfcatch tags but can use the cferror tag.

Any help would be wonderful.

Thanks


 
If they won't let you use the cftry/cfcatch tags then you will have to manually check the db for each condition you are &quot;catching&quot;. For example, rather than just catch the error that you are trying to update a record that doesn't exist, you will have to query the DB table to first see if the record exists. If it doesn't, you will return the appropriate message and, if it does exist, you can then submit the update as another query statement.

I have to say, I really don't envy your situation - it sounds like they're taking away a lot of the power of ColdFusion from you by not letting you do that kind of stuff. They're making your (coding) life a lot harder than it has to be because they've essentially removed your ability to write &quot;generic&quot; error handling routines and forced you to manually check for each error condition. This has the additional disadvantage of causing a user to see a ColdFusion error page for any error condition that occurs (rather than you being able to make it a more &quot;user friendly&quot; message and/or hide information you really may not want the user seeing, as you could do with a cfcatch on &quot;any&quot; error type). Also, on a very busy server cftry/cfcatch can be used together to automatically re-attempt things such as DB updates that fail just because the server was too busy at that moment to perform the update. You're not going to be able to take advantage of that. Are you in the situation where pointing that out to one of your &quot;higher ups&quot; might get you access to use those features?
 
1)Why won't they let you use cftry/cfcatch....

2) how do they plan to keep you from using it.....


------------------------------------------------------------------------------
brannonH
if( !succeed ) try( );
 
Good question, I asked them those 2 questions also. It is a shared web host for the company. Lets just say this is a fortune 500 company so it is big.

they don't let us use cftry because it doesn't report errors to them, so if there is an error and we catch it as a custom error they won't be able to tell the error on there administrative site.

They do code scans of all hosted pages. They then send code violations and warnings to the website admins and tell them if they don't fix it they will shut the site down.

I can understand why they do this...and yes it causes more headaches for me and limits the power of CF, but i got the problem fixed.

They won't let me use it so i went to the IT and said i can't do this with your limits so fix it. and luckily they did. Thanks for your help. I was going to do it manually for checking the records. i just don't know how to do it in CF. in asp i used the BOF and EOF to check for empty queries.
 
There I can help you. You reference the &quot;recordset&quot; returned by the query with the name specified in the cfquery tag. All you have to do is check the &quot;recordcount&quot; property of the &quot;recordset&quot; and that means you got no records returned. So if you have a cfquery...

<cfquery name=&quot;MyQuery&quot; datasource=&quot;Blah&quot; dbtype=&quot;oledb&quot;>
select *
from SomeTable
</cfquery>

...you can just check this way:

<cfif MyQuery.recordcount EQ 0>
<!--- No records returned --->
<cfelse>
<!--- I got some records --->
</cfif>

Viola!
 
You can tell them that all they need to do is write a small custom tag to write the errors that the catch tag catches to a text file called yourCompany.text in a respected directory. then they could read every webclients error log with theirs ......... seems like they are making a mountain out of a mole hill if you ask me........



------------------------------------------------------------------------------
brannonH
if( !succeed ) try( );
 
oh i agree...they are being very difficult so that they have an easier time. Yeah i brought that up and our IT department is backedup so my project for custom tags would be put on the back burner but they did mention that as a possibility.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top