Re: Using try/catch all over the place a good thing?

2005-10-20 Thread Barney Boisvert
I'd probably throw an exception and let the calling page catch it if
it wants to. By using a return code, you're allowing the calling page
to ignore a failure, while an exception forces the calling page to
explicitly deal with the exceptional circumstance.  You could just let
the DB exception trickle up, but that's breaking encapsulation, so you
should throw an OperationFailed exception, or something generic like
that, and declare that it can be thrown either in the HINT attribute,
or in the non-standard THROWS attribute.

cheers,
barneyb

On 10/19/05, Will Tomlinson [EMAIL PROTECTED] wrote:
 ok, here's what I'm using in my cfc. Is this an ok way to handle it?

 cffunction name=deleteProduct access=public returntype=numeric 
 hint=Deletes a product
 cfargument name=prodID required=yes type=numeric hint=Need one 
 product ID
cfset var complete = 1
cfset var deleteproduct = 
  cftry
   cfquery datasource=#VARIABLES.dsn# name=deleteproduct
   DELETE FROM tblproducts
   WHERE prodID = cfqueryparam cfsqltype=cf_sql_integer
   value=#ARGUMENTS.prodID#
   /cfquery
 cfcatch type=databasecfset complete = 0/cfcatch
  /cftry
 cfreturn complete
/cffunction

 If something screws up, I set complete to 0. Then in my page, I check to see 
 if it's 0, and display a message.

 Thanks,
 Will


--
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 100 invites.

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221682
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


RE: Using try/catch all over the place a good thing?

2005-10-19 Thread Andrew Scott
You could also do this..

cftry
  cfcatch type=database
   Catch database error
   cfabort if you need to
  /cfcatch
  cfcatch type=something else
   !--- do something else ---
  /cfcatch
/cftry



Regards
Andrew Scott
Analyst Programmer

CMS Transport Systems
Level 2/33 Bank Street
South Melbourne, Victoria, 3205

Phone: 03 9699 7988  -  Fax: 03 9699 7976

Quote:
I gather, young man, that you wish to be a Member of Parliament. The first
lesson that you must learn is, when I call for statistics about the rate of
infant mortality, what I want is proof that fewer babies died when I was
Prime Minister than when anyone else was Prime Minister. That is a political
statistic. - Sir Winston Leonard Spencer Churchill

--
-Original Message-
From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 19 October 2005 1:36 PM
To: CF-Talk
Subject: RE: Using try/catch all over the place a good thing?

heh Bad Idea(tm) I like that


 1. Your code has errors.
There are plenty of cases where you want no indication of an error to be
shown to a user (which is exactly what a site wide error handler would
indicate), especially when the error involves uploading foreign files to
your server or your database choking on the info they tried to pass to it.
There are of course better ways to deal with both but they aren't guaranteed
to stop any errors from being displayed like an empty cfcatch.

 2. Your user is giving your code input that you didn't anticipate.
See above

 3. There is an external problems, like a database being unavailable.
I doubt that skipping over an error or two, for whatever reason, would be
your biggest problem if there was no database available to your application

 There are cases where a try/catch block is
 warranted, so long as it's used properly

What is the proper use and does it exclude catching errors that might be
thrown by a cffile or cfquery?

As for wrapping cftry/catch around EVERYTHING, I missed that part. I'm not
sure how big of a performance hit that would be but it would undoubtedly be
one. Not to mention it might tend to make a lazy CF'r out of ya ;)

...:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com


-Original Message-
From: Justin D. Scott [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 18, 2005 10:51 PM
To: CF-Talk
Subject: RE: Using try/catch all over the place a good thing?

 I'm wrapping some cftry/catchs around my cffiles
 and cfquerys. It works pretty sweet if I use
 just an empty catch. 

Hi Will, what is sweet about it, exactly?  If your code is generating an
error, it means one of several things:


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.12.2/140 - Release Date: 10/18/2005
 





~|
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:221444
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: Using try/catch all over the place a good thing?

2005-10-19 Thread Justin D. Scott
  There are cases where a try/catch block is
  warranted, so long as it's used properly
 
 What is the proper use and does it exclude catching
 errors that might be thrown by a cffile or cfquery?

A proper use would be what you described, where you have a file coming in to
be imported and there may be errors when trying to parse it, or an
unexpected result from a web service call, or any number of other places
like this.  Whether you use a site-wide error template or catch the error,
you probably want to let the user know about it (either there's a problem
with the site, a problem with their input, or the planets aren't aligned, or
whatever).  As for CFFILE and CFQUERY, sure, you can catch individual errors
if you like, but I wouldn't bother unless you plan on doing something
specific with them.

Now if you have an instance where the only thing you're using a database for
is pulling banner ads, and the DB isn't available, that would be a case
where you could catch the error, ignore it, and safely move on.  Just make
sure you have some checks in your banner display code for the existence of
your variables and such before trying to display it.  No sense in stopping
the visitor from viewing the site just because your ads are unavailable for
whatever reason.

 As for wrapping cftry/catch around EVERYTHING, I missed
 that part.

That was what started the thread, or at least that's the impression I got
from the original poster; that he wanted to wrap everything in one big
try/catch block.


-Justin Scott


~|
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:221461
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: Using try/catch all over the place a good thing?

2005-10-19 Thread Bobby Hartsfield
I missed commenting on the EVERYTHING since I thought he was looking for a
solution to this...

 I can see a problem though where the cffile might 
 work, then the query fails but you don't know it


 you probably want to let the user know about it 
Usually, yes, but again, there are plenty of occassions where you do not
want to do that or do not want to interrupt the remaining experience because
of a trivial error.

As for the planets being aligned... I usually just tell them they have to
hold their mouth right when surfing  lol

..:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com



-Original Message-
From: Justin D. Scott [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 19, 2005 8:01 AM
To: CF-Talk
Subject: RE: Using try/catch all over the place a good thing?

  There are cases where a try/catch block is
  warranted, so long as it's used properly
 
 What is the proper use and does it exclude catching
 errors that might be thrown by a cffile or cfquery?

A proper use would be what you described, where you have a file coming in to
be imported and there may be errors when trying to parse it, or an
unexpected result from a web service call, or any number of other places
like this.  Whether you use a site-wide error template or catch the error,
you probably want to let the user know about it (either there's a problem
with the site, a problem with their input, or the planets aren't aligned, or
whatever).  As for CFFILE and CFQUERY, sure, you can catch individual errors
if you like, but I wouldn't bother unless you plan on doing something
specific with them.

Now if you have an instance where the only thing you're using a database for
is pulling banner ads, and the DB isn't available, that would be a case
where you could catch the error, ignore it, and safely move on.  Just make
sure you have some checks in your banner display code for the existence of
your variables and such before trying to display it.  No sense in stopping
the visitor from viewing the site just because your ads are unavailable for
whatever reason.

 As for wrapping cftry/catch around EVERYTHING, I missed
 that part.

That was what started the thread, or at least that's the impression I got
from the original poster; that he wanted to wrap everything in one big
try/catch block.


-Justin Scott




~|
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:221466
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: Using try/catch all over the place a good thing?

2005-10-19 Thread Munson, Jacob
I had a very funny experience with cftry/catch.  I was taking
responsibility for a huge and kludgey application that was the result of
2-3 different developers over time.  The developer before me had put
try/catches all over the place.  They just caught 'any' and emailed him
the error.  I wasn't really paying attention to this until one day I
accidentally created an infinite loop on a page.  I was trying to figure
out why my page was just sitting and spinning with nothing happening,
then I decided it must be stuck in a loop.  No big deal, I fixed it and
moved on.  A couple of hours later I got a call from the previous
developer, who had just received 2-3 thousand emails from the app!
Serves him right for setting it up that way.  :-D

 -Original Message-
 From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, October 19, 2005 6:46 AM
 To: CF-Talk
 Subject: RE: Using try/catch all over the place a good thing?
 
 I missed commenting on the EVERYTHING since I thought he was 
 looking for a
 solution to this...
 
  I can see a problem though where the cffile might 
  work, then the query fails but you don't know it
 
 
  you probably want to let the user know about it 
 Usually, yes, but again, there are plenty of occassions where 
 you do not
 want to do that or do not want to interrupt the remaining 
 experience because
 of a trivial error.
 
 As for the planets being aligned... I usually just tell them 
 they have to
 hold their mouth right when surfing  lol
 
 ..:.:.:.:.:.:.:.:.:.:.:.:.:.:.
 Bobby Hartsfield
 http://acoderslife.com

This transmission may contain information that is privileged, confidential 
and/or exempt from disclosure under applicable law. If you are not the intended 
recipient, you are hereby notified that any disclosure, copying, distribution, 
or use of the information contained herein (including any reliance thereon) is 
STRICTLY PROHIBITED. If you received this transmission in error, please 
immediately contact the sender and destroy the material in its entirety, 
whether in electronic or hard copy format. Thank you. A1.



~|
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:221483
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: Using try/catch all over the place a good thing?

2005-10-19 Thread Troy Simpson
You could not have planned it any better than that!!
Run that loop again  LOL

On 10/19/05, Munson, Jacob [EMAIL PROTECTED] wrote:
 I had a very funny experience with cftry/catch.  I was taking
 responsibility for a huge and kludgey application that was the result of
 2-3 different developers over time.  The developer before me had put
 try/catches all over the place.  They just caught 'any' and emailed him
 the error.  I wasn't really paying attention to this until one day I
 accidentally created an infinite loop on a page.  I was trying to figure
 out why my page was just sitting and spinning with nothing happening,
 then I decided it must be stuck in a loop.  No big deal, I fixed it and
 moved on.  A couple of hours later I got a call from the previous
 developer, who had just received 2-3 thousand emails from the app!
 Serves him right for setting it up that way.  :-D
--
Thanks,
Troy Simpson

~|
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:221485
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


RE: Using try/catch all over the place a good thing?

2005-10-19 Thread Munson, Jacob
:)  I would, but I don't maintain that app anymore (thankfully). 

 -Original Message-
 From: Troy Simpson [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, October 19, 2005 9:29 AM
 To: CF-Talk
 Subject: Re: Using try/catch all over the place a good thing?
 
 You could not have planned it any better than that!!
 Run that loop again  LOL
 
 On 10/19/05, Munson, Jacob [EMAIL PROTECTED] wrote:
  I had a very funny experience with cftry/catch.  I was taking
  responsibility for a huge and kludgey application that was 
 the result of
  2-3 different developers over time.  The developer before me had put
  try/catches all over the place.  They just caught 'any' and 
 emailed him
  the error.  I wasn't really paying attention to this until one day I
  accidentally created an infinite loop on a page.  I was 
 trying to figure
  out why my page was just sitting and spinning with nothing 
 happening,
  then I decided it must be stuck in a loop.  No big deal, I 
 fixed it and
  moved on.  A couple of hours later I got a call from the previous
  developer, who had just received 2-3 thousand emails from the app!
  Serves him right for setting it up that way.  :-D

This transmission may contain information that is privileged, confidential 
and/or exempt from disclosure under applicable law. If you are not the intended 
recipient, you are hereby notified that any disclosure, copying, distribution, 
or use of the information contained herein (including any reliance thereon) is 
STRICTLY PROHIBITED. If you received this transmission in error, please 
immediately contact the sender and destroy the material in its entirety, 
whether in electronic or hard copy format. Thank you. A1.



~|
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:221489
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


RE: Using try/catch all over the place a good thing?

2005-10-19 Thread Mike Klostermeyer
Done that as well, but evidently I was a lot more patient than you, as I
generated 34,000 emails!

Mike

-Original Message-
From: Munson, Jacob [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 19, 2005 10:21 AM
To: CF-Talk
Subject: RE: Using try/catch all over the place a good thing?


I had a very funny experience with cftry/catch.  I was taking
responsibility for a huge and kludgey application that was the result of
2-3 different developers over time.  The developer before me had put
try/catches all over the place.  They just caught 'any' and emailed him
the error.  I wasn't really paying attention to this until one day I
accidentally created an infinite loop on a page.  I was trying to figure
out why my page was just sitting and spinning with nothing happening,
then I decided it must be stuck in a loop.  No big deal, I fixed it and
moved on.  A couple of hours later I got a call from the previous
developer, who had just received 2-3 thousand emails from the app!
Serves him right for setting it up that way.  :-D

 -Original Message-
 From: Bobby Hartsfield [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, October 19, 2005 6:46 AM
 To: CF-Talk
 Subject: RE: Using try/catch all over the place a good thing?

 I missed commenting on the EVERYTHING since I thought he was
 looking for a
 solution to this...

  I can see a problem though where the cffile might
  work, then the query fails but you don't know it


  you probably want to let the user know about it
 Usually, yes, but again, there are plenty of occassions where
 you do not
 want to do that or do not want to interrupt the remaining
 experience because
 of a trivial error.

 As for the planets being aligned... I usually just tell them
 they have to
 hold their mouth right when surfing  lol

 ..:.:.:.:.:.:.:.:.:.:.:.:.:.:.
 Bobby Hartsfield
 http://acoderslife.com

This transmission may contain information that is privileged, confidential
and/or exempt from disclosure under applicable law. If you are not the
intended recipient, you are hereby notified that any disclosure, copying,
distribution, or use of the information contained herein (including any
reliance thereon) is STRICTLY PROHIBITED. If you received this transmission
in error, please immediately contact the sender and destroy the material in
its entirety, whether in electronic or hard copy format. Thank you. A1.





~|
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:221492
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: Using try/catch all over the place a good thing?

2005-10-19 Thread Matt Robertson
Another consequence of emailing errors, if you are sending diagnostic
info with the error (and you should be), you could be emailing
passwords, credit card numbers etc. etc. that are passed in the form
scope.  Consider that when developing your error handling.  I like to
store them in a db, with a fallback to a write to disk.  I only email
myself a 'you've got errors' email, if I send the email at all as
opposed to checking the log (I use a server monitor to find things
like dead db's killing the site).  Hand in hand with that is a
cfscheduled task that deletes all errors older than X days.

Also, consider using a site wide error handler AND a cferror tag AND,
on a granular level, cftry/cfcatch.  Use cftry/cfcatch to protect
individual blocks of code where you want a specific error handled a
specific way (like a mime type failure on an upload).  Use cferror as
your application's general error handler and use a sitewide handler to
bat cleanup in case something goes wrong with Plans A and B.

--
--mattRobertson--
Janitor, MSB Web Systems
mysecretbase.com

~|
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:221503
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


RE: Using try/catch all over the place a good thing?

2005-10-19 Thread Dave Watts
 Also, consider using a site wide error handler AND a cferror tag AND,
 on a granular level, cftry/cfcatch.  Use cftry/cfcatch to protect
 individual blocks of code where you want a specific error handled a
 specific way (like a mime type failure on an upload).  Use cferror as
 your application's general error handler and use a sitewide handler to
 bat cleanup in case something goes wrong with Plans A and B.

Amen. I couldn't have said it better.

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!


~|
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:221515
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


RE: Using try/catch all over the place a good thing?

2005-10-19 Thread Bobby Hartsfield
Haha yes, it does serve him right! I would have hit the loop again... but
then again... im pretty mean :)

If you needed the info surrounding an error to be emailed to you, I'd
definitely just use the site wide error handler like Justin described.

 
..:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
-Original Message-
From: Munson, Jacob [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 19, 2005 11:21 AM
To: CF-Talk
Subject: RE: Using try/catch all over the place a good thing?

I had a very funny experience with cftry/catch.  I was taking
responsibility for a huge and kludgey application that was the result of
2-3 different developers over time.  The developer before me had put
try/catches all over the place.  They just caught 'any' and emailed him
the error.  I wasn't really paying attention to this until one day I
accidentally created an infinite loop on a page.  I was trying to figure
out why my page was just sitting and spinning with nothing happening,
then I decided it must be stuck in a loop.  No big deal, I fixed it and
moved on.  A couple of hours later I got a call from the previous
developer, who had just received 2-3 thousand emails from the app!
Serves him right for setting it up that way.  :-D

 -Original Message-
 From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, October 19, 2005 6:46 AM
 To: CF-Talk
 Subject: RE: Using try/catch all over the place a good thing?
 
 I missed commenting on the EVERYTHING since I thought he was 
 looking for a
 solution to this...
 
  I can see a problem though where the cffile might 
  work, then the query fails but you don't know it
 
 
  you probably want to let the user know about it 
 Usually, yes, but again, there are plenty of occassions where 
 you do not
 want to do that or do not want to interrupt the remaining 
 experience because
 of a trivial error.
 
 As for the planets being aligned... I usually just tell them 
 they have to
 hold their mouth right when surfing  lol
 
 ..:.:.:.:.:.:.:.:.:.:.:.:.:.:.
 Bobby Hartsfield
 http://acoderslife.com

This transmission may contain information that is privileged, confidential
and/or exempt from disclosure under applicable law. If you are not the
intended recipient, you are hereby notified that any disclosure, copying,
distribution, or use of the information contained herein (including any
reliance thereon) is STRICTLY PROHIBITED. If you received this transmission
in error, please immediately contact the sender and destroy the material in
its entirety, whether in electronic or hard copy format. Thank you. A1.





~|
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:221522
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


RE: Using try/catch all over the place a good thing?

2005-10-19 Thread Bobby Hartsfield
Well put. I believe I may just stop including any details at all in my error
emails after reading that but instead, as you described, just send an email
that says basically, 'you’ve got errors at mysite.com'. And then just build
a reusable error interface component for my sites.

It would...
A) keep me from building the elaborate outlook folder structure to hold any
error emails that might be triggered by the error handlers of my sites

B) Keep the errors located at their origin and easily found

C) Give the resources for a better error ticket reporting method and track
history of the application.

Thanks for that input.

..:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com


-Original Message-
From: Matt Robertson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 19, 2005 12:48 PM
To: CF-Talk
Subject: Re: Using try/catch all over the place a good thing?

Another consequence of emailing errors, if you are sending diagnostic
info with the error (and you should be), you could be emailing
passwords, credit card numbers etc. etc. that are passed in the form
scope.  Consider that when developing your error handling.  I like to
store them in a db, with a fallback to a write to disk.  I only email
myself a 'you've got errors' email, if I send the email at all as
opposed to checking the log (I use a server monitor to find things
like dead db's killing the site).  Hand in hand with that is a
cfscheduled task that deletes all errors older than X days.

Also, consider using a site wide error handler AND a cferror tag AND,
on a granular level, cftry/cfcatch.  Use cftry/cfcatch to protect
individual blocks of code where you want a specific error handled a
specific way (like a mime type failure on an upload).  Use cferror as
your application's general error handler and use a sitewide handler to
bat cleanup in case something goes wrong with Plans A and B.

--
--mattRobertson--
Janitor, MSB Web Systems
mysecretbase.com



~|
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:221523
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: Using try/catch all over the place a good thing?

2005-10-19 Thread Will Tomlinson
This is all great guys! Thanks for all the tips. Learnin' lots as usual. 

Yeah, I'm specifically workin' with a file upload then insert query. I like the 
try/catch approach because it drops the user right back where he was, not to 
another page (error page) where he's trying to figure out what to do next. 

This is in a cfc and I'm setting a flag if it fails. If the flag exists, I can 
let him know something terribly wrong happened and he needs to grab a life 
vest. 

Will   

~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221553
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


Re: Using try/catch all over the place a good thing?

2005-10-19 Thread Will Tomlinson
ok, here's what I'm using in my cfc. Is this an ok way to handle it?

cffunction name=deleteProduct access=public returntype=numeric 
hint=Deletes a product
cfargument name=prodID required=yes type=numeric hint=Need one product 
ID
   cfset var complete = 1
   cfset var deleteproduct = 
 cftry
  cfquery datasource=#VARIABLES.dsn# name=deleteproduct
  DELETE FROM tblproducts
  WHERE prodID = cfqueryparam cfsqltype=cf_sql_integer
  value=#ARGUMENTS.prodID#
  /cfquery  
cfcatch type=databasecfset complete = 0/cfcatch  
 /cftry   
cfreturn complete
   /cffunction

If something screws up, I set complete to 0. Then in my page, I check to see if 
it's 0, and display a message. 

Thanks,
Will

~|
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:221599
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


RE: Using try/catch all over the place a good thing?

2005-10-18 Thread Bobby Hartsfield
Any reason you can't just do this? 

cftry

cffile action=

cfquery name=...
DE DO DO DO DE DA DA DA
/cfquery

cfcatch type=any/cfcatch
/cftry


 
..:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com

-Original Message-
From: Will Tomlinson [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 18, 2005 10:23 PM
To: CF-Talk
Subject: Using try/catch all over the place a good thing?

I'm wrapping some cftry/catchs around my cffiles and cfquerys. It works
pretty sweet if I use just an empty catch. 

Is it ok practice to wrap EVERYTHING with these? I like the empty catch
cause it just drops you right back on the page with no errors. I can see a
problem though where the cffile might work, then the query fails but you
don't know it. 

cftry
cffile action=
cfcatch type=any/cfcatch
/cftry

cftry
cfquery name=...
DE DO DO DO DE DA DA DA
/cfquery
cfcatch type=database/cfcatch
/cftry

Thanks,
Will



~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221430
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: Using try/catch all over the place a good thing?

2005-10-18 Thread Justin D. Scott
 I'm wrapping some cftry/catchs around my cffiles
 and cfquerys. It works pretty sweet if I use
 just an empty catch. 

Hi Will, what is sweet about it, exactly?  If your code is generating an
error, it means one of several things:

1. Your code has errors.
2. Your user is giving your code input that you didn't anticipate.
3. There is an external problems, like a database being unavailable.

Ignoring those errors and allowing the page to continue is probably a Bad
Idea(tm) in most cases.  There are cases where a try/catch block is
warranted, so long as it's used properly.  I would advocate a site-wide
exception handler instead of just wrapping a try/catch block around
everything.

You can do this in the Application.cfm file with the CFERROR tag.  Point it
to an error handler that will display a friendly we're sorry, but there was
an error display, and then e-mail all of the error information, the URL the
user called, and possibly a CFDUMP of the various variable scopes to aid in
correcting the problem.

Your goal should be to never receive one of these error reports, and to
promptly correct problems that the handler does report so that your users
will have the best possible experience on your web sites.


-Justin Scott


~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221431
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


RE: Using try/catch all over the place a good thing?

2005-10-18 Thread Bobby Hartsfield
heh Bad Idea(tm) I like that


 1. Your code has errors.
There are plenty of cases where you want no indication of an error to be
shown to a user (which is exactly what a site wide error handler would
indicate), especially when the error involves uploading foreign files to
your server or your database choking on the info they tried to pass to it.
There are of course better ways to deal with both but they aren’t guaranteed
to stop any errors from being displayed like an empty cfcatch.

 2. Your user is giving your code input that you didn't anticipate.
See above

 3. There is an external problems, like a database being unavailable.
I doubt that skipping over an error or two, for whatever reason, would be
your biggest problem if there was no database available to your application

 There are cases where a try/catch block is
 warranted, so long as it's used properly

What is the proper use and does it exclude catching errors that might be
thrown by a cffile or cfquery?

As for wrapping cftry/catch around EVERYTHING, I missed that part. I'm not
sure how big of a performance hit that would be but it would undoubtedly be
one. Not to mention it might tend to make a lazy CF'r out of ya ;)

..:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com


-Original Message-
From: Justin D. Scott [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 18, 2005 10:51 PM
To: CF-Talk
Subject: RE: Using try/catch all over the place a good thing?

 I'm wrapping some cftry/catchs around my cffiles
 and cfquerys. It works pretty sweet if I use
 just an empty catch. 

Hi Will, what is sweet about it, exactly?  If your code is generating an
error, it means one of several things:


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.12.2/140 - Release Date: 10/18/2005
 



~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221440
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