@@ -23,22 +23,20 @@ #import "OFTCPSocket.h" #import "common.h" @implementation OFConnectionFailedException -+ (instancetype)exceptionWithClass: (Class)class - socket: (OFTCPSocket*)socket - host: (OFString*)host - port: (uint16_t)port -{ - return [[[self alloc] initWithClass: class - socket: socket - host: host - port: port] autorelease]; -} - -- initWithClass: (Class)class ++ (instancetype)exceptionWithHost: (OFString*)host + port: (uint16_t)port + socket: (OFTCPSocket*)socket +{ + return [[[self alloc] initWithHost: host + port: port + socket: socket] autorelease]; +} + +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -46,20 +44,19 @@ } abort(); } -- initWithClass: (Class)class - socket: (OFTCPSocket*)socket - host: (OFString*)host - port: (uint16_t)port +- initWithHost: (OFString*)host + port: (uint16_t)port + socket: (OFTCPSocket*)socket { - self = [super initWithClass: class]; + self = [super init]; @try { - _socket = [socket retain]; _host = [host copy]; + _socket = [socket retain]; _port = port; _errNo = GET_SOCK_ERRNO; } @catch (id e) { [self release]; @throw e; @@ -68,27 +65,22 @@ return self; } - (void)dealloc { - [_socket release]; [_host release]; + [_socket release]; [super dealloc]; } - (OFString*)description { return [OFString stringWithFormat: @"A connection to %@ on port %" @PRIu16 @" could not be " - @"established in class %@! " ERRFMT, _host, _port, _inClass, - ERRPARAM]; -} - -- (OFTCPSocket*)socket -{ - OF_GETTER(_socket, false) + @"established in socket of type %@! " ERRFMT, _host, _port, + [_socket class], ERRPARAM]; } - (OFString*)host { OF_GETTER(_host, false) @@ -96,11 +88,16 @@ - (uint16_t)port { return _port; } + +- (OFTCPSocket*)socket +{ + OF_GETTER(_socket, false) +} - (int)errNo { return _errNo; } @end