improve error checking and reporting when making a tcp/ip connection.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24168 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2006-11-29 19:57:38 +00:00
parent fa13ef9c99
commit b8209430fd
5 changed files with 45 additions and 8 deletions

View file

@ -929,16 +929,25 @@ strerror(int eno)
* additional information can be placed in it by higher level code.
*/
+ (NSError*) _last
{
#if defined(__MINGW32__)
return [self _systemError: GetLastError()];
#else
extern int errno;
return [self _systemError: errno];
#endif
}
+ (NSError*) _systemError: (long)code
{
NSError *error;
NSString *domain;
NSDictionary *info;
long code;
#if defined(__MINGW32__)
LPVOID lpMsgBuf;
NSString *message;
code = GetLastError();
domain = NSOSStatusErrorDomain;
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
@ -949,10 +958,8 @@ strerror(int eno)
message, NSLocalizedDescriptionKey,
nil];
#else
extern int errno;
NSString *message;
code = errno;
/* FIXME ... not all are POSIX, should we use NSMachErrorDomain for some? */
domain = NSPOSIXErrorDomain;
message = [NSString stringWithCString: strerror(code)