ObjFW  Diff

Differences From Artifact [5ebb9198c3]:

To Artifact [3a43359e82]:


14
15
16
17
18
19
20

21
22
23
24

25
26
27
28

29
30
31
32
33

34
35
36
37
38
39

40
41
42
43
44
45
46
47
48

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103


104
105
14
15
16
17
18
19
20
21
22
23
24

25

26
27

28

29
30
31

32

33
34
35
36

37

38
39
40
41
42
43


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62



































63

64
65
66
67







+



-
+
-


-
+
-



-
+
-




-
+
-






-
-
+


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

-
+
+


 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFResolveHostFailedException.h"
#import "OFDNSQueryFailedException.h"
#import "OFString.h"

@implementation OFResolveHostFailedException
@synthesize host = _host, recordClass = _recordClass, recordType = _recordType;
@synthesize host = _host, addressFamily = _addressFamily, error = _error;
@synthesize error = _error;

+ (instancetype)exceptionWithHost: (OFString *)host
		      recordClass: (of_dns_resource_record_class_t)recordClass
		    addressFamily: (of_socket_address_family_t)addressFamily
		       recordType: (of_dns_resource_record_type_t)recordType
			    error: (of_dns_resolver_error_t)error
{
	return [[[self alloc] initWithHost: host
			       recordClass: recordClass
			     addressFamily: addressFamily
				recordType: recordType
				     error: error] autorelease];
}

- (instancetype)initWithHost: (OFString *)host
		 recordClass: (of_dns_resource_record_class_t)recordClass
	       addressFamily: (of_socket_address_family_t)addressFamily
		  recordType: (of_dns_resource_record_type_t)recordType
		       error: (of_dns_resolver_error_t)error
{
	self = [super init];

	@try {
		_host = [host copy];
		_recordClass = recordClass;
		_recordType = recordType;
		_addressFamily = addressFamily;
		_error = error;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_host release];

	[super dealloc];
}

- (OFString *)description
{
	OFString *error;

	switch (_error) {
	case OF_DNS_RESOLVER_ERROR_TIMEOUT:
		error = @"The query timed out.";
		break;
	case OF_DNS_RESOLVER_ERROR_CANCELED:
		error = @"The query was canceled.";
		break;
	case OF_DNS_RESOLVER_ERROR_NO_RESULT:
		error = @"No result for the specified host with the specified "
		    @"type and class.";
		break;
	case OF_DNS_RESOLVER_ERROR_SERVER_INVALID_FORMAT:
		error = @"The server considered the query to be malformed.";
		break;
	case OF_DNS_RESOLVER_ERROR_SERVER_FAILURE:
		error = @"The server was unable to process due to an internal "
		    @"error.";
		break;
	case OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR:
		error = @"The server returned an error that the domain does "
		    @"not exist.";
		break;
	case OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED:
		error = @"The server does not have support for the requested "
		    @"query.";
	case OF_DNS_RESOLVER_ERROR_SERVER_REFUSED:
		error = @"The server refused the query.";
		break;
	default:
		error = @"Unknown error.";
		break;
	}

	return [OFString stringWithFormat:
	    @"The host %@ could not be resolved: %@", _host, error];
	    @"The host %@ could not be resolved: %@",
	    _host, of_dns_resolver_error_to_string(_error)];
}
@end