Index: ObjFW.xcodeproj/project.pbxproj ================================================================== --- ObjFW.xcodeproj/project.pbxproj +++ ObjFW.xcodeproj/project.pbxproj @@ -357,12 +357,12 @@ 4B8B170D133A3C11007CD8B3 /* OFConditionBroadcastFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1702133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.m */; }; 4B8B170E133A3C11007CD8B3 /* OFConditionSignalFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1704133A3B8E007CD8B3 /* OFConditionSignalFailedException.m */; }; 4B8B170F133A3C11007CD8B3 /* OFConditionWaitFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1706133A3B8E007CD8B3 /* OFConditionWaitFailedException.m */; }; 4B90B78D133AD46700BD33CB /* OFAlreadyConnectedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B787133AD46700BD33CB /* OFAlreadyConnectedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B90B78E133AD46700BD33CB /* OFAlreadyConnectedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B788133AD46700BD33CB /* OFAlreadyConnectedException.m */; }; - 4B90B78F133AD46700BD33CB /* OFNotConnectedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B789133AD46700BD33CB /* OFNotConnectedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4B90B790133AD46700BD33CB /* OFNotConnectedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B78A133AD46700BD33CB /* OFNotConnectedException.m */; }; + 4B90B78F133AD46700BD33CB /* OFNotOpenException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B789133AD46700BD33CB /* OFNotOpenException.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4B90B790133AD46700BD33CB /* OFNotOpenException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B78A133AD46700BD33CB /* OFNotOpenException.m */; }; 4B90B791133AD46700BD33CB /* OFSetOptionFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B78B133AD46700BD33CB /* OFSetOptionFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B90B792133AD46700BD33CB /* OFSetOptionFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B78C133AD46700BD33CB /* OFSetOptionFailedException.m */; }; 4B90B79E133AD87D00BD33CB /* OFAcceptFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B794133AD87D00BD33CB /* OFAcceptFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B90B79F133AD87D00BD33CB /* OFAcceptFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B795133AD87D00BD33CB /* OFAcceptFailedException.m */; }; 4B90B7A0133AD87D00BD33CB /* OFAddressTranslationFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B796133AD87D00BD33CB /* OFAddressTranslationFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -858,12 +858,12 @@ 4B8B1704133A3B8E007CD8B3 /* OFConditionSignalFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConditionSignalFailedException.m; path = src/exceptions/OFConditionSignalFailedException.m; sourceTree = ""; }; 4B8B1705133A3B8E007CD8B3 /* OFConditionWaitFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConditionWaitFailedException.h; path = src/exceptions/OFConditionWaitFailedException.h; sourceTree = ""; }; 4B8B1706133A3B8E007CD8B3 /* OFConditionWaitFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConditionWaitFailedException.m; path = src/exceptions/OFConditionWaitFailedException.m; sourceTree = ""; }; 4B90B787133AD46700BD33CB /* OFAlreadyConnectedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFAlreadyConnectedException.h; path = src/exceptions/OFAlreadyConnectedException.h; sourceTree = ""; }; 4B90B788133AD46700BD33CB /* OFAlreadyConnectedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFAlreadyConnectedException.m; path = src/exceptions/OFAlreadyConnectedException.m; sourceTree = ""; }; - 4B90B789133AD46700BD33CB /* OFNotConnectedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFNotConnectedException.h; path = src/exceptions/OFNotConnectedException.h; sourceTree = ""; }; - 4B90B78A133AD46700BD33CB /* OFNotConnectedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFNotConnectedException.m; path = src/exceptions/OFNotConnectedException.m; sourceTree = ""; }; + 4B90B789133AD46700BD33CB /* OFNotOpenException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFNotOpenException.h; path = src/exceptions/OFNotOpenException.h; sourceTree = ""; }; + 4B90B78A133AD46700BD33CB /* OFNotOpenException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFNotOpenException.m; path = src/exceptions/OFNotOpenException.m; sourceTree = ""; }; 4B90B78B133AD46700BD33CB /* OFSetOptionFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFSetOptionFailedException.h; path = src/exceptions/OFSetOptionFailedException.h; sourceTree = ""; }; 4B90B78C133AD46700BD33CB /* OFSetOptionFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFSetOptionFailedException.m; path = src/exceptions/OFSetOptionFailedException.m; sourceTree = ""; }; 4B90B794133AD87D00BD33CB /* OFAcceptFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFAcceptFailedException.h; path = src/exceptions/OFAcceptFailedException.h; sourceTree = ""; }; 4B90B795133AD87D00BD33CB /* OFAcceptFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFAcceptFailedException.m; path = src/exceptions/OFAcceptFailedException.m; sourceTree = ""; }; 4B90B796133AD87D00BD33CB /* OFAddressTranslationFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFAddressTranslationFailedException.h; path = src/exceptions/OFAddressTranslationFailedException.h; sourceTree = ""; }; @@ -1103,14 +1103,14 @@ 4B17FFA0133A3332003E6DCD /* OFMalformedXMLException.m */, 4B17FF8D133A3034003E6DCD /* OFMemoryNotPartOfObjectException.h */, 4B17FF8E133A3034003E6DCD /* OFMemoryNotPartOfObjectException.m */, 4B7DD5831894358400990FD6 /* OFMoveItemFailedException.h */, 4B7DD5841894358400990FD6 /* OFMoveItemFailedException.m */, - 4B90B789133AD46700BD33CB /* OFNotConnectedException.h */, - 4B90B78A133AD46700BD33CB /* OFNotConnectedException.m */, 4B17FF75133A2B18003E6DCD /* OFNotImplementedException.h */, 4B17FF76133A2B18003E6DCD /* OFNotImplementedException.m */, + 4B90B789133AD46700BD33CB /* OFNotOpenException.h */, + 4B90B78A133AD46700BD33CB /* OFNotOpenException.m */, 4B35C64C1ADAD30A003DB666 /* OFObserveFailedException.h */, 4B35C64D1ADAD30A003DB666 /* OFObserveFailedException.m */, 4B55A107133AC05100B58A93 /* OFOpenItemFailedException.h */, 4B55A108133AC05100B58A93 /* OFOpenItemFailedException.m */, 4B17FF81133A2DFB003E6DCD /* OFOutOfMemoryException.h */, @@ -1759,12 +1759,12 @@ 4B90B7A6133AD87D00BD33CB /* OFListenFailedException.h in Headers */, 4B6743F1163C384A00EB1E59 /* OFLockFailedException.h in Headers */, 4B17FFA1133A3335003E6DCD /* OFMalformedXMLException.h in Headers */, 4B17FF8F133A3036003E6DCD /* OFMemoryNotPartOfObjectException.h in Headers */, 4B7DD5851894358500990FD6 /* OFMoveItemFailedException.h in Headers */, - 4B90B78F133AD46700BD33CB /* OFNotConnectedException.h in Headers */, 4B17FF77133A2B18003E6DCD /* OFNotImplementedException.h in Headers */, + 4B90B78F133AD46700BD33CB /* OFNotOpenException.h in Headers */, 4B35C64E1ADAD30A003DB666 /* OFObserveFailedException.h in Headers */, 4B55A10A133AC05100B58A93 /* OFOpenItemFailedException.h in Headers */, 4B17FF83133A2DFB003E6DCD /* OFOutOfMemoryException.h in Headers */, 4B17FF7B133A2C15003E6DCD /* OFOutOfRangeException.h in Headers */, 4B55A112133AC24600B58A93 /* OFReadFailedException.h in Headers */, @@ -2141,12 +2141,12 @@ 4B90B7A7133AD87D00BD33CB /* OFListenFailedException.m in Sources */, 4B6743F2163C384A00EB1E59 /* OFLockFailedException.m in Sources */, 4B17FFA2133A3335003E6DCD /* OFMalformedXMLException.m in Sources */, 4B17FF90133A3036003E6DCD /* OFMemoryNotPartOfObjectException.m in Sources */, 4B7DD5861894358500990FD6 /* OFMoveItemFailedException.m in Sources */, - 4B90B790133AD46700BD33CB /* OFNotConnectedException.m in Sources */, 4B17FF78133A2B18003E6DCD /* OFNotImplementedException.m in Sources */, + 4B90B790133AD46700BD33CB /* OFNotOpenException.m in Sources */, 4B35C64F1ADAD30A003DB666 /* OFObserveFailedException.m in Sources */, 4B55A10B133AC05100B58A93 /* OFOpenItemFailedException.m in Sources */, 4B17FF84133A2DFB003E6DCD /* OFOutOfMemoryException.m in Sources */, 4B17FF7C133A2C15003E6DCD /* OFOutOfRangeException.m in Sources */, 4B55A113133AC24600B58A93 /* OFReadFailedException.m in Sources */, Index: src/OFHTTPClient.m ================================================================== --- src/OFHTTPClient.m +++ src/OFHTTPClient.m @@ -31,11 +31,10 @@ #import "OFHTTPRequestFailedException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFInvalidServerReplyException.h" -#import "OFNotConnectedException.h" #import "OFNotImplementedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFTruncatedDataException.h" Index: src/OFHTTPServer.m ================================================================== --- src/OFHTTPServer.m +++ src/OFHTTPServer.m @@ -31,11 +31,11 @@ #import "OFTimer.h" #import "OFAlreadyConnectedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" -#import "OFNotConnectedException.h" +#import "OFNotOpenException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFWriteFailedException.h" #import "socket_helpers.h" @@ -239,11 +239,11 @@ length: (size_t)length { void *pool; if (_socket == nil) - @throw [OFNotConnectedException exceptionWithSocket: self]; + @throw [OFNotOpenException exceptionWithObject: self]; if (!_headersSent) [self OF_sendHeaders]; if (!_chunked) { @@ -263,11 +263,11 @@ } - (void)close { if (_socket == nil) - @throw [OFNotConnectedException exceptionWithSocket: self]; + @throw [OFNotOpenException exceptionWithObject: self]; if (!_headersSent) [self OF_sendHeaders]; if (_chunked) Index: src/OFStreamSocket.m ================================================================== --- src/OFStreamSocket.m +++ src/OFStreamSocket.m @@ -22,11 +22,11 @@ #include #import "OFStreamSocket.h" #import "OFInitializationFailedException.h" -#import "OFNotConnectedException.h" +#import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSetOptionFailedException.h" #import "OFWriteFailedException.h" @@ -57,11 +57,11 @@ length: (size_t)length { ssize_t ret; if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithSocket: self]; + @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: ENOTCONN]; @@ -91,11 +91,11 @@ - (void)lowlevelWriteBuffer: (const void*)buffer length: (size_t)length { if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithSocket: self]; + @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length errNo: ENOTCONN]; @@ -162,11 +162,11 @@ } - (void)close { if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithSocket: self]; + @throw [OFNotOpenException exceptionWithObject: self]; close(_socket); _socket = INVALID_SOCKET; _atEndOfStream = false; Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -39,12 +39,12 @@ #import "OFBindFailedException.h" #import "OFConnectionFailedException.h" #import "OFGetOptionFailedException.h" #import "OFInvalidArgumentException.h" #import "OFListenFailedException.h" -#import "OFNotConnectedException.h" #import "OFNotImplementedException.h" +#import "OFNotOpenException.h" #import "OFOutOfMemoryException.h" #import "OFSetOptionFailedException.h" #import "socket.h" #import "socket_helpers.h" @@ -481,11 +481,11 @@ } - (void)listenWithBackLog: (int)backLog { if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithSocket: self]; + @throw [OFNotOpenException exceptionWithObject: self]; if (listen(_socket, backLog) == -1) @throw [OFListenFailedException exceptionWithSocket: self backLog: backLog @@ -566,11 +566,11 @@ - (OFString*)remoteAddress { OFString *ret; if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithSocket: self]; + @throw [OFNotOpenException exceptionWithObject: self]; if (_address == NULL) @throw [OFInvalidArgumentException exception]; of_address_to_string_and_port(_address, _addressLength, &ret, NULL); Index: src/OFUDPSocket.m ================================================================== --- src/OFUDPSocket.m +++ src/OFUDPSocket.m @@ -28,11 +28,11 @@ #import "OFRunLoop+Private.h" #import "OFBindFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" -#import "OFNotConnectedException.h" +#import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #import "socket.h" @@ -469,11 +469,11 @@ sender: (of_udp_socket_address_t*)sender { ssize_t ret; if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithSocket: self]; + @throw [OFNotOpenException exceptionWithObject: self]; sender->length = (socklen_t)sizeof(sender->address); #ifndef _WIN32 if ((ret = recvfrom(_socket, buffer, length, 0, @@ -524,11 +524,11 @@ - (void)sendBuffer: (const void*)buffer length: (size_t)length receiver: (of_udp_socket_address_t*)receiver { if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithSocket: self]; + @throw [OFNotOpenException exceptionWithObject: self]; #ifndef _WIN32 if (sendto(_socket, buffer, length, 0, (struct sockaddr*)&receiver->address, receiver->length) < length) @throw [OFWriteFailedException @@ -584,11 +584,11 @@ } - (void)close { if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithSocket: self]; + @throw [OFNotOpenException exceptionWithObject: self]; close(_socket); _socket = INVALID_SOCKET; } @end Index: src/ObjFW.h ================================================================== --- src/ObjFW.h +++ src/ObjFW.h @@ -139,14 +139,12 @@ #endif #import "OFLockFailedException.h" #import "OFMalformedXMLException.h" #import "OFMemoryNotPartOfObjectException.h" #import "OFMoveItemFailedException.h" -#ifdef OF_HAVE_SOCKETS -# import "OFNotConnectedException.h" -#endif #import "OFNotImplementedException.h" +#import "OFNotOpenException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFReadOrWriteFailedException.h" Index: src/exceptions/Makefile ================================================================== --- src/exceptions/Makefile +++ src/exceptions/Makefile @@ -25,10 +25,11 @@ OFLockFailedException.m \ OFMalformedXMLException.m \ OFMemoryNotPartOfObjectException.m \ OFMoveItemFailedException.m \ OFNotImplementedException.m \ + OFNotOpenException.m \ OFOpenItemFailedException.m \ OFOutOfMemoryException.m \ OFOutOfRangeException.m \ OFReadFailedException.m \ OFReadOrWriteFailedException.m \ @@ -52,11 +53,10 @@ OFAlreadyConnectedException.m \ OFBindFailedException.m \ OFConnectionFailedException.m \ OFHTTPRequestFailedException.m \ OFListenFailedException.m \ - OFNotConnectedException.m \ OFObserveFailedException.m SRCS_THREADS = OFConditionBroadcastFailedException.m \ OFConditionSignalFailedException.m \ OFConditionStillWaitingException.m \ OFConditionWaitFailedException.m \ DELETED src/exceptions/OFNotConnectedException.h Index: src/exceptions/OFNotConnectedException.h ================================================================== --- src/exceptions/OFNotConnectedException.h +++ src/exceptions/OFNotConnectedException.h @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#import "OFException.h" - -#ifndef OF_HAVE_SOCKETS -# error No sockets available! -#endif - -/*! - * @class OFNotConnectedException \ - * OFNotConnectedException.h ObjFW/OFNotConnectedException.h - * - * @brief An exception indicating a socket is not connected or bound. - */ -@interface OFNotConnectedException: OFException -{ - id _socket; -} - -#ifdef OF_HAVE_PROPERTIES -@property (readonly, retain) id socket; -#endif - -/*! - * @brief Creates a new, autoreleased not connected exception. - * - * @param socket The socket which is not connected - * @return A new, autoreleased not connected exception - */ -+ (instancetype)exceptionWithSocket: (id)socket; - -/*! - * @brief Initializes an already allocated not connected exception. - * - * @param socket The socket which is not connected - * @return An initialized not connected exception - */ -- initWithSocket: (id)socket; - -/*! - * @brief Returns the socket which is not connected. - * - * @return The socket which is not connected - */ -- (id)socket; -@end DELETED src/exceptions/OFNotConnectedException.m Index: src/exceptions/OFNotConnectedException.m ================================================================== --- src/exceptions/OFNotConnectedException.m +++ src/exceptions/OFNotConnectedException.m @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#include "config.h" - -#import "OFNotConnectedException.h" -#import "OFString.h" - -@implementation OFNotConnectedException -+ (instancetype)exceptionWithSocket: (id)socket -{ - return [[[self alloc] initWithSocket: socket] autorelease]; -} - -- init -{ - OF_INVALID_INIT_METHOD -} - -- initWithSocket: (id)socket -{ - self = [super init]; - - _socket = [socket retain]; - - return self; -} - -- (void)dealloc -{ - [_socket release]; - - [super dealloc]; -} - -- (OFString*)description -{ - return [OFString stringWithFormat: - @"The socket of type %@ is not connected or bound!", - [_socket class]]; -} - -- (id)socket -{ - OF_GETTER(_socket, true) -} -@end ADDED src/exceptions/OFNotOpenException.h Index: src/exceptions/OFNotOpenException.h ================================================================== --- src/exceptions/OFNotOpenException.h +++ src/exceptions/OFNotOpenException.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFException.h" + +/*! + * @class OFNotOpenException OFNotOpenException.h ObjFW/OFNotOpenException.h + * + * @brief An exception indicating an object is not open, connected or bound. + */ +@interface OFNotOpenException: OFException +{ + id _object; +} + +#ifdef OF_HAVE_PROPERTIES +@property (readonly, retain) id object; +#endif + +/*! + * @brief Creates a new, autoreleased not open exception. + * + * @param object The object which is not open, connected or bound + * @return A new, autoreleased not open exception + */ ++ (instancetype)exceptionWithObject: (id)object; + +/*! + * @brief Initializes an already allocated not open exception. + * + * @param object The object which is not open, connected or bound + * @return An initialized not open exception + */ +- initWithObject: (id)object; + +/*! + * @brief Returns the object which is not open, connected or bound. + * + * @return The object which is not open, connected or bound + */ +- (id)object; +@end ADDED src/exceptions/OFNotOpenException.m Index: src/exceptions/OFNotOpenException.m ================================================================== --- src/exceptions/OFNotOpenException.m +++ src/exceptions/OFNotOpenException.m @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "OFNotOpenException.h" +#import "OFString.h" + +@implementation OFNotOpenException ++ (instancetype)exceptionWithObject: (id)object +{ + return [[[self alloc] initWithObject: object] autorelease]; +} + +- init +{ + OF_INVALID_INIT_METHOD +} + +- initWithObject: (id)object +{ + self = [super init]; + + _object = [object retain]; + + return self; +} + +- (void)dealloc +{ + [_object release]; + + [super dealloc]; +} + +- (OFString*)description +{ + return [OFString stringWithFormat: + @"The object of type %@ is not open, connected or bound!", + [_object class]]; +} + +- (id)object +{ + OF_GETTER(_object, true) +} +@end