@@ -30,19 +30,19 @@ #if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS) # include "threading.h" #endif -#import "OFAddressTranslationFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS) # import "OFLockFailedException.h" # import "OFUnlockFailedException.h" #endif +#import "OFResolveHostFailedException.h" #import "socket_helpers.h" #if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS) static of_mutex_t mutex; @@ -73,26 +73,29 @@ if (!of_mutex_lock(&mutex)) @throw [OFLockFailedException exception]; @try { # endif - int error; - - if ((error = getaddrinfo([host UTF8String], portCString, &hints, - &res0)) != 0) - @throw [OFAddressTranslationFailedException + if (getaddrinfo([host UTF8String], portCString, &hints, + &res0) != 0) + @throw [OFResolveHostFailedException exceptionWithHost: host - error: error]; + recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN + recordType: 0 + error: OF_DNS_RESOLVER_ERROR_UNKNOWN]; count = 0; for (res = res0; res != NULL; res = res->ai_next) count++; if (count == 0) { freeaddrinfo(res0); - @throw [OFAddressTranslationFailedException - exceptionWithHost: host]; + @throw [OFResolveHostFailedException + exceptionWithHost: host + recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN + recordType: 0 + error: OF_DNS_RESOLVER_ERROR_NO_RESULT]; } if ((ret = calloc(count + 1, sizeof(*ret))) == NULL) { freeaddrinfo(res0); @throw [OFOutOfMemoryException @@ -190,21 +193,26 @@ return ret; } if ((he = gethostbyname((const void *)[host UTF8String])) == NULL || he->h_addrtype != AF_INET) - @throw [OFAddressTranslationFailedException + @throw [OFResolveHostFailedException exceptionWithHost: host - error: h_errno]; + recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN + recordType: 0 + error: OF_DNS_RESOLVER_ERROR_UNKNOWN]; count = 0; for (ip = (char **)he->h_addr_list; *ip != NULL; ip++) count++; if (count == 0) - @throw [OFAddressTranslationFailedException - exceptionWithHost: host]; + @throw [OFResolveHostFailedException + exceptionWithHost: host + recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN + recordType: 0 + error: OF_DNS_RESOLVER_ERROR_NO_RESULT]; if ((ret = calloc(count + 1, sizeof(*ret))) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: (count + 1) * sizeof(*ret)];