• 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
Re: NSError: why returned directly?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSError: why returned directly?


  • Subject: Re: NSError: why returned directly?
  • From: Erik Buck <email@hidden>
  • Date: Wed, 26 Apr 2006 07:07:01 -0700 (PDT)

My own opinion from many years of experience is that exceptions are abused vastly more often then they are used well.

  We have all been reminded that “goto” is seldom a good idea.  Well, an exception is a “goto” with a destination that can not be predicted by the author of the code that generates the exception (“goto”).   Exceptions are the most pathological example of goto that is possible.

  IMHO, exceptions should be reserved for “this should never happen” type situations.  Frankly, I think exceptions should be reserved for situations where NSAssert() is used.

  There is a difference between expected “reasonable” errors and exceptions.  For example, trying to create a file on a full file system is an entirely predictable error.  It is an expected error.  Attempting to access an index beyond the end of an array is an expected error.  Even though Foundation raises an NSRangeException or NSInvalidArgumentException, I don’t think it should.

  My experience with Ada, Java, C++, Eiffel, and Objective-C has been consistent that exceptions are virtually useless in all of these languages and to the extent framework designers used exceptions, the frameworks become harder to reuse.

  In a sense, I think Apple is doing the right thing by reporting errors via method return value and providing a means to get more information about the error.  I am ambivalent about error details being returned by reference.

  However, unlike JOAR, I think Cocoa newbies need to be comfortable enough in C that parameters returned by reference are perfectly understandable.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSError: why returned directly?
      • From: Ondra Cada <email@hidden>
    • Re: NSError: why returned directly?
      • From: glenn andreas <email@hidden>
    • Re: NSError: why returned directly?
      • From: Jonathon Mah <email@hidden>
  • Prev by Date: Horizontal NSTableView OR How I learned to Bind NSTableView Columns Instead of Rows
  • Next by Date: Re: Trying to read PICT data using Quartz functions
  • Previous by thread: Re: NSError: why returned directly?
  • Next by thread: Re: NSError: why returned directly?
  • Index(es):
    • Date
    • Thread