Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

OSErr - Any way of getting textual representation of error?

Hi guys,

If I have an OSErr is there a way of getting a string describing the error for logging?

Cheers

Andy

MacPro and MacBookPro, Mac OS X (10.5.2)

Posted on May 26, 2008 11:27 AM

Reply
Question marked as Best reply

Posted on May 26, 2008 2:03 PM

You might start by converting to an NSError, using NSError's +errorWithDomain:code:userInfo method. If you call -description on that error, you'll get a string with a textual representation of all the elements of the error.

However, I can't see any method that will give you just the underlying OSStatus error text, without the rest of the elements.

I hate to suggest parsing the string returned from -description, but that may be what you need to do.
2 replies
Question marked as Best reply

May 26, 2008 2:03 PM in response to AndrewCapon

You might start by converting to an NSError, using NSError's +errorWithDomain:code:userInfo method. If you call -description on that error, you'll get a string with a textual representation of all the elements of the error.

However, I can't see any method that will give you just the underlying OSStatus error text, without the rest of the elements.

I hate to suggest parsing the string returned from -description, but that may be what you need to do.

OSErr - Any way of getting textual representation of error?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.