Re: cftry and cfcatch
Thank you so much, Pine et al. It works wonderful. jl On 2/8/06, John McKown [EMAIL PROTECTED] wrote: Sounds like you do not want TRY/CATCH... that is triggered on a failure. You really want to use CFSWITCH/CFCASE. -- John McKown President, Delaware.Net ICQ: 1812513 We host Fusebox.org and all of our apps are Fusebox/ColdFusion/BlueDragon compliant. John Lucania wrote: I have two queries: cfquery name=checksrv datasource=master SELECT @@SERVICENAME; /cfquery cfquery name=checkage datasource=master SELECT count (program_name) FROM master.dbo.sysprocesses WITH (NOLOCK) WHERE program_name LIKE '%Agent%' /cfquery I want to be notified through cfmail if 1) query checksrv doesn't return MSSQLSERVER then, MSSQLSERVER not returned in cfmail or query checkage doesn't return 2 then, Agent not returned 2 in cfmail or both of checksrv and checkage don't return then, MSSQLSERVER not returned and Agent not returned 2 in cfmail or 2) query checksrv cannot be run then, MSSQLSERVER Not Avail in cfmail or query checkage cannot be run then, Agent Not Avail in cfmail or both of checksrv and checkage cannot be run then, MSSQLSERVER Not Avail and Agent Not Avail in cfmail. Any ideas? tia, jl ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:233475 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=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: cftry and cfcatch
I'm guessing here but I think your two queries are using stored procedures. So, use cfstoredproc to check the return values. Then, your first issue will be resolved. Then use nested cftry and cfcatch for each stored proc to resolve the second issue. So probably something like this: cftry !--- Set the variable for your second issue here. --- cfset notRunQuery = 0 cfset problemQueryNumber = 0 cftry cfstoredproc name=checksrv datasource=master returnCode=YES result=storedProc1Return SELECT @@SERVICENAME; /cfstoredproc cfcatch type = database cfset notRunQuery = notRunQuery + 1 cfset problemQueryNumber = 1 cfthrow type = yourOwnError /cfcatch /cftry cftry cfstoredproc name=checkage datasource=master returnCode=YES result=storedProc2Return SELECT count (program_name) FROM master.dbo.sysprocesses WITH (NOLOCK) WHERE program_name LIKE '%Agent%' /cfstoredproc cfcatch type = database cfset notRunQuery = notRunQuery + 1 cfset problemQueryNumber = 2 !--- Throw your own error for the outermost cfcatch to catch --- cfthrow type = yourOwnError /cfcatch /cftry cfcatch type =yourOwnError cfif notRunQuery is 2 !--- Send MSSQLSERVER Not Avail and Agent Not Avail in cfmail. --- cfelseif notRunQuery is 1 cfif problemQueryNumber = 1 !--- Send MSSQLSERVER Not Avail in cfmail. --- cfelseif problemQueryNumber = 2 !--- Send Agent Not Avail in cfmail. --- /cfif /cfif /cfcatch /cftry !--- Check the errors(return values) with from two stored procedures. Do CFMail here by checking two return structs (storedProc1Return and storedProc2Return) --- HTH, Pine -Original Message- From: John Lucania [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 07, 2006 6:00 PM To: CF-Talk Subject: cftry and cfcatch I have two queries: cfquery name=checksrv datasource=master SELECT @@SERVICENAME; /cfquery cfquery name=checkage datasource=master SELECT count (program_name) FROM master.dbo.sysprocesses WITH (NOLOCK) WHERE program_name LIKE '%Agent%' /cfquery I want to be notified through cfmail if 1) query checksrv doesn't return MSSQLSERVER then, MSSQLSERVER not returned in cfmail or query checkage doesn't return 2 then, Agent not returned 2 in cfmail or both of checksrv and checkage don't return then, MSSQLSERVER not returned and Agent not returned 2 in cfmail or 2) query checksrv cannot be run then, MSSQLSERVER Not Avail in cfmail or query checkage cannot be run then, Agent Not Avail in cfmail or both of checksrv and checkage cannot be run then, MSSQLSERVER Not Avail and Agent Not Avail in cfmail. Any ideas? tia, jl ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:231649 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=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: cftry and cfcatch
I was in a hurry when I typed the previous response and found a glitch in the logic. In the inner cfcatch blocks, I am throwing the errors. So, whenever there is a problem, the yourOwnError exception will be thrown. That means you will never see Send MSSQLSERVER Not Avail and Agent Not Avail in cfmail. To resolve that, at the top of my head, just remove the cfthrow tags in the cfcatch blocks. Handle it outside the cftry and cfcatch. I don't think you would even need to nest the cftry anymore. So, the revised version will be like this: !--- Set the variable for your second issue here. --- cfset notRunQuery = 0 cfset problemQueryNumber = 0 cftry cfstoredproc name=checksrv datasource=master returnCode=YES result=storedProc1Return SELECT @@SERVICENAME; /cfstoredproc cfcatch type = database cfset notRunQuery = notRunQuery + 1 cfset problemQueryNumber = 1 /cfcatch /cftry cftry cfstoredproc name=checkage datasource=master returnCode=YES result=storedProc2Return SELECT count (program_name) FROM master.dbo.sysprocesses WITH (NOLOCK) WHERE program_name LIKE '%Agent%' /cfstoredproc cfcatch type = database cfset notRunQuery = notRunQuery + 1 cfset problemQueryNumber = 2 /cfcatch /cftry cfif notRunQuery is 2 !--- Send MSSQLSERVER Not Avail and Agent Not Avail in cfmail. --- cfelseif notRunQuery is 1 cfif problemQueryNumber = 1 !--- Send MSSQLSERVER Not Avail in cfmail. --- cfelseif problemQueryNumber = 2 !--- Send Agent Not Avail in cfmail. --- /cfif /cfif !--- Check the errors(return values) with from two stored procedures. Do CFMail here by checking two return structs (storedProc1Return and storedProc2Return) --- -Original Message- From: PINE Phyo Z Sent: Wednesday, February 08, 2006 8:53 AM To: 'cf-talk@houseoffusion.com' Subject: RE: cftry and cfcatch I'm guessing here but I think your two queries are using stored procedures. So, use cfstoredproc to check the return values. Then, your first issue will be resolved. Then use nested cftry and cfcatch for each stored proc to resolve the second issue. So probably something like this: cftry !--- Set the variable for your second issue here. --- cfset notRunQuery = 0 cfset problemQueryNumber = 0 cftry cfstoredproc name=checksrv datasource=master returnCode=YES result=storedProc1Return SELECT @@SERVICENAME; /cfstoredproc cfcatch type = database cfset notRunQuery = notRunQuery + 1 cfset problemQueryNumber = 1 cfthrow type = yourOwnError /cfcatch /cftry cftry cfstoredproc name=checkage datasource=master returnCode=YES result=storedProc2Return SELECT count (program_name) FROM master.dbo.sysprocesses WITH (NOLOCK) WHERE program_name LIKE '%Agent%' /cfstoredproc cfcatch type = database cfset notRunQuery = notRunQuery + 1 cfset problemQueryNumber = 2 !--- Throw your own error for the outermost cfcatch to catch --- cfthrow type = yourOwnError /cfcatch /cftry cfcatch type =yourOwnError cfif notRunQuery is 2 !--- Send MSSQLSERVER Not Avail and Agent Not Avail in cfmail. --- cfelseif notRunQuery is 1 cfif problemQueryNumber = 1 !--- Send MSSQLSERVER Not Avail in cfmail. --- cfelseif problemQueryNumber = 2 !--- Send Agent Not Avail in cfmail. --- /cfif /cfif /cfcatch /cftry !--- Check the errors(return values) with from two stored procedures. Do CFMail here by checking two return structs (storedProc1Return and storedProc2Return) --- HTH, Pine -Original Message- From: John Lucania [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 07, 2006 6:00 PM To: CF-Talk Subject: cftry and cfcatch I have two queries: cfquery name=checksrv datasource=master SELECT @@SERVICENAME; /cfquery cfquery name=checkage datasource=master SELECT count (program_name) FROM master.dbo.sysprocesses WITH (NOLOCK) WHERE program_name LIKE '%Agent%' /cfquery I want to be notified through cfmail if 1) query checksrv doesn't return MSSQLSERVER then, MSSQLSERVER not returned in cfmail or query checkage doesn't return 2 then, Agent not returned 2 in cfmail or both of checksrv
Re: cftry and cfcatch
Sounds like you do not want TRY/CATCH... that is triggered on a failure. You really want to use CFSWITCH/CFCASE. -- John McKown President, Delaware.Net ICQ: 1812513 We host Fusebox.org and all of our apps are Fusebox/ColdFusion/BlueDragon compliant. John Lucania wrote: I have two queries: cfquery name=checksrv datasource=master SELECT @@SERVICENAME; /cfquery cfquery name=checkage datasource=master SELECT count (program_name) FROM master.dbo.sysprocesses WITH (NOLOCK) WHERE program_name LIKE '%Agent%' /cfquery I want to be notified through cfmail if 1) query checksrv doesn't return MSSQLSERVER then, MSSQLSERVER not returned in cfmail or query checkage doesn't return 2 then, Agent not returned 2 in cfmail or both of checksrv and checkage don't return then, MSSQLSERVER not returned and Agent not returned 2 in cfmail or 2) query checksrv cannot be run then, MSSQLSERVER Not Avail in cfmail or query checkage cannot be run then, Agent Not Avail in cfmail or both of checksrv and checkage cannot be run then, MSSQLSERVER Not Avail and Agent Not Avail in cfmail. Any ideas? tia, jl ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:231703 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=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: CFTRY and CFCATCH
Try CFDUMP on the CFCATCH structure. That should show you the type of the exception. cftry cfquery ...SQL... /cfquery cfcatch type=any cfdump var=#cfcatch# /cfcatch /cftry I would say, in this case, it is probably a database exception. M!ke -Original Message- From: Mickael [mailto:[EMAIL PROTECTED] Sent: Monday, October 10, 2005 7:21 AM To: CF-Talk Subject: CFTRY and CFCATCH Hi All, I have never really had a good handle on CFTRY and CFCATCH. If I have an error on my website as follows The request has exceeded the allowable time limit Tag: CFQUERY What type of cfcatch is that? Or can that not be caught by CFCatch? Mike ~| 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:220537 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=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: cftry cfcatch/cfcatch/cftry
structured exception handling should be kept as close to the questionable code as possible. One of it's error types is "missinginclude", which should also help to illustrate the logical error in placing opening and closing error handling tags in seperate files to be included. What you can do, is include a cferror tag in your application.cfm tag or at the top of any template containing CFTRY/CFCATCH/CFTHROW and wrap the rest of the page or the code in question, with the CFTRY tags. ~Simon Simon Horwith Certified ColdFusion Developer Fig Leaf Software 1400 16th St NW, # 220 Washington DC 20036 202.797.6570 (direct line) www.figleaf.com -Original Message- From: Neil H. [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 13, 2000 11:38 AM To: CF-Talk Subject: cftry cfcatch/cfcatch/cftry I just found, disappointingly enough that you can't have a cftry at the top of a document via a CFinclude and the rest in another include at the bottom? Is there a work around. I don't want to use a handler, and I want the same error checking code on every page. Please advise or throw ideas (even bones will do) Thanks, Neil p.s. Running CF 4.51. - Original Message - From: "Hales, John M" [EMAIL PROTECTED] To: "CF-Talk" [EMAIL PROTECTED] Sent: Wednesday, December 13, 2000 11:17 AM Subject: RE: CFreport and crystal reports I could never get it to work. We just use CF to pass the parameters to Crystal, and the CR Web Server to display the reports. That works well for us. HTH Mike Hales -Original Message- From: Katie Bessiere [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 13, 2000 11:08 AM To: CF-Talk Subject: CFreport and crystal reports has anyone had any luck using CFREPORT with crystal reports 8? i've tried the workaround that Allaire recommends and I still can't get the tag to work. It's very frustrating.. If anyone has any ideas, please let me know.. katie Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: cftry cfcatch/cfcatch/cftry
Alternately, you could have a main page that has a cftry/cfcatch block, and include the meat of the page within (a la Fusebox). Worth a shot, neh? -- Jamie Keane Programmer SolutionMasters, Inc. 9111 Monroe Rd., Suite 100 Charlotte, NC 28270 www.solutionmasters.com 704.563.5559 x 228 Voice 704.849.9291 Fax -Original Message- From: Neil H. [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Date: Wednesday, December 13, 2000 11:37 AM Subject: cftry cfcatch/cfcatch/cftry I just found, disappointingly enough that you can't have a cftry at the top of a document via a CFinclude and the rest in another include at the bottom? Is there a work around. I don't want to use a handler, and I want the same error checking code on every page. Please advise or throw ideas (even bones will do) Thanks, Neil p.s. Running CF 4.51. - Original Message - From: "Hales, John M" [EMAIL PROTECTED] To: "CF-Talk" [EMAIL PROTECTED] Sent: Wednesday, December 13, 2000 11:17 AM Subject: RE: CFreport and crystal reports I could never get it to work. We just use CF to pass the parameters to Crystal, and the CR Web Server to display the reports. That works well for us. HTH Mike Hales -Original Message- From: Katie Bessiere [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 13, 2000 11:08 AM To: CF-Talk Subject: CFreport and crystal reports has anyone had any luck using CFREPORT with crystal reports 8? i've tried the workaround that Allaire recommends and I still can't get the tag to work. It's very frustrating.. If anyone has any ideas, please let me know.. katie Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: cftry cfcatch/cfcatch/cftry
Haven't tried it but theoretically you might be able to: application.cfm would contain: cf_error_check onrequestend.cfm would contain: /cf_error_check error_check.cfm would contain: !--pseudo code-- if executionmode eq start cftry cfcatch else /cfcatch/cftry onrequestend.cfm might choke on the /cf_error_check though. Maybe some parameter passing would be in order. Jeff -Original Message- From: Neil H. [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 13, 2000 11:38 AM To: CF-Talk Subject: cftry cfcatch/cfcatch/cftry I just found, disappointingly enough that you can't have a cftry at the top of a document via a CFinclude and the rest in another include at the bottom? Is there a work around. I don't want to use a handler, and I want the same error checking code on every page. Please advise or throw ideas (even bones will do) Thanks, Neil p.s. Running CF 4.51. - Original Message - From: "Hales, John M" [EMAIL PROTECTED] To: "CF-Talk" [EMAIL PROTECTED] Sent: Wednesday, December 13, 2000 11:17 AM Subject: RE: CFreport and crystal reports I could never get it to work. We just use CF to pass the parameters to Crystal, and the CR Web Server to display the reports. That works well for us. HTH Mike Hales -Original Message- From: Katie Bessiere [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 13, 2000 11:08 AM To: CF-Talk Subject: CFreport and crystal reports has anyone had any luck using CFREPORT with crystal reports 8? i've tried the workaround that Allaire recommends and I still can't get the tag to work. It's very frustrating.. If anyone has any ideas, please let me know.. katie Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: cftry cfcatch/cfcatch/cftry
On 12/13/00, Neil H. penned: I just found, disappointingly enough that you can't have a cftry at the top of a document via a CFinclude and the rest in another include at the bottom? Is there a work around. I don't want to use a handler, and I want the same error checking code on every page. Please advise or throw ideas (even bones will do) A bone: If you can put this at the VERY bottom and VERY top of every page, perhaps at the end of application.cfm and put the closing in OnRequestEnd.cfm? -- Bud Schneehagen - Tropical Web Creations _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ColdFusion Solutions / eCommerce Development [EMAIL PROTECTED] http://www.twcreations.com/ 954.721.3452 ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: cftry cfcatch/cfcatch/cftry
This doesn't work. You can't have a page the contains just cftry included with other stuff below it. You would expect to since cfinclude just moves the contents into the main page. I want to use a standard code set for error handling. Also I don't want to rely on fusebox techniques since I don't want url parameters. Thanks, Neil - Original Message - From: "Bud" [EMAIL PROTECTED] To: "CF-Talk" [EMAIL PROTECTED] Sent: Wednesday, December 13, 2000 12:45 PM Subject: Re: cftry cfcatch/cfcatch/cftry On 12/13/00, Neil H. penned: I just found, disappointingly enough that you can't have a cftry at the top of a document via a CFinclude and the rest in another include at the bottom? Is there a work around. I don't want to use a handler, and I want the same error checking code on every page. Please advise or throw ideas (even bones will do) A bone: If you can put this at the VERY bottom and VERY top of every page, perhaps at the end of application.cfm and put the closing in OnRequestEnd.cfm? -- Bud Schneehagen - Tropical Web Creations _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ColdFusion Solutions / eCommerce Development [EMAIL PROTECTED] http://www.twcreations.com/ 954.721.3452 ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: cftry cfcatch/cfcatch/cftry (the solution)
Ok, you wanted a hint, here's big a hint. Obviously, the advantage to using a global CFTRY/CFCATCH is that variables are still scoped in the exception block, unlike the global exception handler. The open and close cftry (as you said) must be in the same template, the solutions is surprisingly simple. I've implemented the following code in pre 4.5 systems, and it's worked great: In the Application.cfm: cftry cfinclude template="#cgi.script_name#" cfabort cfcatch type="ALL" cfinclude tempalte="myexceptionhandler.cfm" /cfcatch /cftry This code includes the requested template, so you turn the normal execution thread a little inside-out. But it works. The only thing I've found that doesn't work with it (since you actually NEVER leave the Application.cfm), is ColdFusion's built in server-side form handling (where you do HIDDEN Name="FORMFIELD_REQUIRED"). The nice thing is that it's global and retrofits to any existing code. -Original Message- From: Neil H. [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 13, 2000 8:38 AM To: CF-Talk Subject: cftry cfcatch/cfcatch/cftry I just found, disappointingly enough that you can't have a cftry at the top of a document via a CFinclude and the rest in another include at the bottom? Is there a work around. I don't want to use a handler, and I want the same error checking code on every page. Please advise or throw ideas (even bones will do) Thanks, Neil p.s. Running CF 4.51. - Original Message - From: "Hales, John M" [EMAIL PROTECTED] To: "CF-Talk" [EMAIL PROTECTED] Sent: Wednesday, December 13, 2000 11:17 AM Subject: RE: CFreport and crystal reports I could never get it to work. We just use CF to pass the parameters to Crystal, and the CR Web Server to display the reports. That works well for us. HTH Mike Hales -Original Message- From: Katie Bessiere [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 13, 2000 11:08 AM To: CF-Talk Subject: CFreport and crystal reports has anyone had any luck using CFREPORT with crystal reports 8? i've tried the workaround that Allaire recommends and I still can't get the tag to work. It's very frustrating.. If anyone has any ideas, please let me know.. katie Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: cftry cfcatch/cfcatch/cftry
i use a custom tag. the cftry are included in very page. so the custom tag will perform what ever error handling required. cftry ... codes ... cfcatch type="any" cf_errorhandler /cfcatch /cftry -ken - Original Message - From: Neil H. [EMAIL PROTECTED] Subject: cftry cfcatch/cfcatch/cftry I just found, disappointingly enough that you can't have a cftry at the top of a document via a CFinclude and the rest in another include at the bottom? Is there a work around. I don't want to use a handler, and I want the same error checking code on every page. Please advise or throw ideas (even bones will do) Thanks, Neil p.s. Running CF 4.51. ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists