Re: How to lookup error code such as CFStreamError?
Re: How to lookup error code such as CFStreamError?
- Subject: Re: How to lookup error code such as CFStreamError?
- From: Quinn <email@hidden>
- Date: Thu, 5 Mar 2009 13:18:26 +0000
At 20:33 +0800 5/3/09, µÀéuº· wrote:
I find it very difficult to lookup error code in
mac. For example, I write a program using
CFReadStream to send http request in 10.4. And I
got a CFStreamError with domain 4, error -4. But
How can I know what is the meaning of the domain
and error? I always waste a lot of time on
searching this kind of things. Can anyone help
me? Thank you very much!
If you're working on 10.5 and later things are a
little easier because you can call
CFXxxStreamCopyError rather than
CFXxxStreamGetError. The resulting CFError
object has a more human readable form of the
error domain accessible via CFErrorGetDomain.
If you're on older systems this can be tricky.
You have search the headers for all identifiers
of the form "*CFStreamErrorDomain*". Some of
those are constants, which makes things easier.
Others are "extern int" or "extern SInt32"
values, which you'll have to print in the
debugger. For example:
(gdb) p *(int*)kCFStreamErrorDomainHTTP
$3 = 4
indicates that domain 4 is kCFStreamErrorDomainHTTP.
Once you have the domain you can look in the
header associated with that domain to find a list
of the various codes. For example,
"CFHTTPStream.h" has the following:
/*
* CFStreamErrorHTTP
*
* Discussion:
* Errors from the kCFStreamErrorDomainHTTP domain.
*/
enum CFStreamErrorHTTP {
/*
* Could not parse the request/response.
*/
kCFStreamErrorHTTPParseFailure = -1,
/*
* A loop was detected during redirection.
*/
kCFStreamErrorHTTPRedirectionLoop = -2,
/*
* Could not retreive url for request/response.
*/
kCFStreamErrorHTTPBadURL = -3
};
typedef enum CFStreamErrorHTTP CFStreamErrorHTTP;
Annoyingly this doesn't list -4. I had to go
looking in the source for the meaning of that
value, which is kCFStreamErrorHTTPConnectionLost.
Please file a bug requesting that this constant be put in a public header.
<http://developer.apple.com/bugreporter/>
S+E
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden