• 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: Converting error codes to readable strings?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting error codes to readable strings?


  • Subject: Re: Converting error codes to readable strings?
  • From: Fritz Anderson <email@hidden>
  • Date: Thu, 2 Feb 2006 14:47:43 -0600

On 2 Feb 2006, at 10:22 AM, Jonathan del Strother wrote:

Is there any way to convert error enums into readable strings?

For example, the NSXMLParser might give me parse error number 76, and I have to go look that up to find that that corresponds to NSXMLParserTagNameMismatchError. Not very helpful for users who don't have the NSXMLParser.h header file...

I suppose I could produce my own switch statement to produce an error string for every NSXMLParserError enum value, but is there a better way?

Not knowing of a built-in way to do this, may I suggest using a .plist file to contain a dictionary that maps error numbers to strings? These are easy to load as resources and keep in static globals at +initialize time. A method that wanted error 76 would then convert it to @"76" and pass it in objectForKey:.


A clever regular-expression replace (or BBEdit text factory) could probably convert the enum listing to rough-cut message strings.

	-- F

 --
Fritz Anderson -- http://www.manoverboard.org/
Consulting Programmer -- http://resume.manoverboard.org/
Step into Xcode, Now Available -- http://six.manoverboard.org/


_______________________________________________ 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
References: 
 >Converting error codes to readable strings? (From: Jonathan del Strother <email@hidden>)

  • Prev by Date: Re: Fix Depracated call in Apple Sample Code?
  • Next by Date: Re: Preferred hight of NSTextField
  • Previous by thread: Converting error codes to readable strings?
  • Next by thread: Re: Converting error codes to readable strings?
  • Index(es):
    • Date
    • Thread