• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Error and Exception Handling: When to use
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error and Exception Handling: When to use


  • Subject: Error and Exception Handling: When to use
  • From: Nelson Santos <email@hidden>
  • Date: Mon, 11 Jun 2007 12:49:22 -0400

Hi everyone,

Does anyone know (or know of any books or articles) about the proper way to implement error handling, particularly in Cocoa development? Development in general is fine too.

I am looking for information about:

1) The proper/standard techniques in developing classes that are bulletproof.
2) When to properly use logging vs. assertions vs exceptions, or combinations of the three.
3) At what layer should exceptions be caught.
4) Which error levels should be reported to the user.
5) General strategies and limits of defensive programming.


This came to mind as I was developing my classes. Say, for example, I have a method that receives an int parameter with an allowed range from 1 to 1000. How do I make sure I don't mistakingly send it a value of 5000? Well, I could implement an assert to warn me. Great! Well, what if I miss something during my development and testing and an incorrect value gets sent to the method? Then I should probably implement an IF statement or something to prevent the method from running. Or maybe raise an exception? Well, that means catching the exception somewhere to handle it. Should the user be notified of it? Do I have to do this for every method that I write that receives parameters? There could be many. Is that efficient? If so, does every method call now need to be in between try/catch?

These questions and more pop up in my head and I'm not sure how to answer them. There must be a general recipe that most developers use when implementing good error handling. Thanks in advance for any help.

Nelson


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Error and Exception Handling: When to use
      • From: Ali Ozer <email@hidden>
  • Prev by Date: Re: WebKit or something else?
  • Next by Date: Client Development Question
  • Previous by thread: Re: Localizing validation error strings with Core Data
  • Next by thread: Re: Error and Exception Handling: When to use
  • Index(es):
    • Date
    • Thread