I'm not going to take this pointless discussion any further - I was merely pointing out that there are some perfectly legitimate use cases for catching System.Exception - you are of course entitled to your own opinion Andrew
-----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Peter Ritchie Sent: Monday, September 19, 2005 12:29 PM To: [email protected] Subject: [Spam:***** SpamScore] Re: [ADVANCED-DOTNET] Best way to handle errors in .net CreateNew: Your "hypothetical" application didn't mention any requirements; so, I assumed it might use any of the available options. Your comment suggested you can simply catch an Exception class and MessageBox.Show(ex.Message) whenever you use File.Open(). My response was there are situations, sometimes outside of your control and predictability, that make that ineffective for a "robust" application. If you're not going to cover all the bases, then your application is not going be robust, however implausible you think a situation is. My point was about robustness. Hypothetically, if the filename cannot be allocated, it will be <null>; in which case ex.Message() isn't going very far... It would be far easier, from a programmer's point of view, to simply not handle any exceptions. Let the exception inform the user what happened they can not do whatever they did to cause the exception when they re-run the application :-). I think we all know how users feel about applications like that. http:://www.peterRitchie.com/ On Mon, 19 Sep 2005 11:46:39 -0400, Eames, Andrew <[EMAIL PROTECTED]> wrote: >See below.. > >-----Original Message----- >From: Unmoderated discussion of advanced .NET topics. >[mailto:[EMAIL PROTECTED] On Behalf Of Peter Ritchie >Sent: Monday, September 19, 2005 11:10 AM >To: [email protected] >Subject: [Spam:***** SpamScore] Re: [ADVANCED-DOTNET] Best way to handle >errors in .net > >Off the top of my head: >* 'The file "filename" already exists.' is sufficient for your users >when >you try use FileMode.CreateNew? I would want to ask the user if they >wish >to overwrite so they don't have to open Windows Explorer and delete the >file. >[Eames, Andrew] I don't recall mentioning that I use FileMode.CreateNew >* 'Access to path "filename" is denied' is sufficient for your users for >*both* files marked as read-only and files they don't have access to via >ACL. The user can do something if the read-only bit is set; they can't >if >their Admin has denied them access via ACL. >[Eames, Andrew] Sure they can - they can go and talk to their Admin :) >* ex.Message is not localized. If I bought a Spanish version of the >software running in English Windows, I still want to see Spanish >messages. >[Eames, Andrew] If you are assuming my app is localized then I have >surely also installed the .NET Spanish language pack which has Spanish >messages >* ArgumentNullException, ArgumentOutOfRangeException: these would >provide >useful messages. >[Eames, Andrew] These exceptions are both impossible in my hypothetical >example of a user typing in a file name >* A "Retry" button would be nice with file access attempts. It would be >hard to decide whether "Retry" is an option without knowing more detail >about the exception. "Retry" on FileNotFoundException, >DirectoryNotFoundException, PathTooLongException, or ArgumentException >just doesn't make sense. >[Eames, Andrew] This is rather getting into specifics about what my >application actually does - I was really just making a general point >about a hypothetical application > >http://www.peterRitchie.com/ > >On Mon, 19 Sep 2005 09:57:44 -0400, Eames, Andrew <[EMAIL PROTECTED]> >wrote: > >>You put up a MessageBox showing ex.Message - in response to the user >>typing in a filename that you can't open >>In fact this is a good case in point where you will be more robust to >>the CLR adding a new exception, not less >> Andrew =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com BEGIN-ANTISPAM-VOTING-LINKS ------------------------------------------------------ Teach CanIt if this mail (ID 4555475) is spam: Spam: http://mail-gw.cognex.com/canit/b.php?c=s&i=4555475&m=0c214f2eb290 Not spam: http://mail-gw.cognex.com/canit/b.php?c=n&i=4555475&m=0c214f2eb290 Forget vote: http://mail-gw.cognex.com/canit/b.php?c=f&i=4555475&m=0c214f2eb290 ------------------------------------------------------ END-ANTISPAM-VOTING-LINKS =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
