@@ -49,10 +49,15 @@ if (string != NULL) free(string); return [super free]; } + +- (id)object +{ + return object; +} - (char*)cString { return string; } @@ -78,12 +83,12 @@ - (char*)cString { if (string != NULL) return string; - asprintf(&string, "ERROR: Could not allocate %zu bytes for object of " - "class %s!\n", req_size, object != nil ? [object name] : "(null)"); + asprintf(&string, "Could not allocate %zu bytes for object of class " + "%s!", req_size, object != nil ? [object name] : "(null)"); return string; } - (size_t)requestedSize @@ -112,16 +117,14 @@ - (char*)cString { if (string != NULL) return string; - asprintf(&string, "ERROR: Memory at %p was not allocated as part of " - "object of class\n" - "ERROR: %s!\n" - "ERROR: -> Not changing memory allocation!\n" - "ERROR: (Hint: It is also possible that you tried to free the same " - "memory twice!)\n", pointer, [object name]); + asprintf(&string, "Memory at %p was not allocated as part of object " + "of class %s, thus the memory allocation was not changed! It is " + "also possible that there was an attempt to free the same memory " + "twice.", pointer, [object name]); return string; } - (void*)pointer @@ -129,26 +132,16 @@ return pointer; } @end @implementation OFOutOfRangeException -+ newWithObject: (id)obj -{ - return [[self alloc] initWithObject: obj]; -} - -- initWithObject: (id)obj -{ - return (self = [super initWithObject: obj]); -} - - (char*)cString { if (string != NULL) return string; - asprintf(&string, "ERROR: Value out of range in object of class %s!\n", + asprintf(&string, "Value out of range in object of class %s!", object != nil ? [object name] : "(null)"); return string; } @end @@ -188,12 +181,12 @@ - (char*)cString { if (string != NULL) return string; - asprintf(&string, "ERROR: Failed to open file %s with mode %s " - "in object of class %s!\n", path, mode, [self name]); + asprintf(&string, "Failed to open file %s with mode %s in object of " + "class %s!", path, mode, [self name]); return string; } - (char*)path @@ -244,12 +237,12 @@ - (char*)cString { if (string != NULL) return string;; - asprintf(&string, "ERROR: Failed to read %zu items of size %zu in " - "object of class %s!\n", req_items, req_size, [object name]); + asprintf(&string, "Failed to read %zu items of size %zu in object of " + "class %s!", req_items, req_size, [object name]); return string; } @end @@ -257,11 +250,37 @@ - (char*)cString { if (string != NULL) return string; - asprintf(&string, "ERROR: Failed to write %zu items of size %zu in " - "object of class %s!\n", req_items, req_size, [object name]); + asprintf(&string, "Failed to write %zu items of size %zu in object of " + "class %s!", req_items, req_size, [object name]); + + return string; +} +@end + +@implementation OFNotConnectedException +- (char*)cString +{ + if (string != NULL) + return string; + + asprintf(&string, "The socket of type %s is not connected or bound!", + [object name]); + + return string; +} +@end + +@implementation OFAlreadyConnectedException +- (char*)cString +{ + if (string != NULL) + return string; + + asprintf(&string, "The socket of type %s is already connected or bound " + "and thus can't be connected or bound again!", [object name]); return string; } @end