Index: src/OFExceptions.m ================================================================== --- src/OFExceptions.m +++ src/OFExceptions.m @@ -51,13 +51,11 @@ #define ERRFMT "Error code was: %d" #define ERRPARAM err #define AT_ERRPARAM err #endif -#ifndef HAVE_ASPRINTF #import "asprintf.h" -#endif @implementation OFAllocFailedException + (Class)class { return self; @@ -123,13 +121,13 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"Could not allocate %zu bytes in class %s!", - req_size, [class name]]; + string = [[OFString alloc] initWithFormat: + @"Could not allocate %zu bytes in class %s!", req_size, + [class name]]; return string; } - (size_t)requestedSize @@ -159,16 +157,15 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"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, [class name]]; + string = [[OFString alloc] initWithFormat: + @"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, [class name]]; return string; } - (void*)pointer @@ -198,14 +195,13 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"The method %s of class %s is not or not fully " - @"implemented!", - SEL_NAME(selector), [class name]]; + string = [[OFString alloc] initWithFormat: + @"The method %s of class %s is not or not fully implemented!", + SEL_NAME(selector), [class name]]; return string; } @end @@ -213,13 +209,12 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"Value out of range in class %s!", - [class name]]; + string = [[OFString alloc] initWithFormat: + @"Value out of range in class %s!", [class name]]; return string; } @end @@ -244,14 +239,13 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"The argument for method %s of class %s is " - @"invalid!", - SEL_NAME(selector), [class name]]; + string = [[OFString alloc] initWithFormat: + @"The argument for method %s of class %s is invalid!", + SEL_NAME(selector), [class name]]; return string; } @end @@ -259,13 +253,12 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"The encoding is invalid for class %s!", - [class name]]; + string = [[OFString alloc] initWithFormat: + @"The encoding is invalid for class %s!", [class name]]; return string; } @end @@ -273,13 +266,12 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"The format is invalid for class %s!", - [class name]]; + string = [[OFString alloc] initWithFormat: + @"The format is invalid for class %s!", [class name]]; return string; } @end @@ -287,13 +279,12 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"Initialization failed for class %s!", - [class name]]; + string = [[OFString alloc] initWithFormat: + @"Initialization failed for class %s!", [class name]]; return string; } @end @@ -331,15 +322,13 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"Failed to open file %s with mode %s in class %s! " - ERRFMT, - [path cString], [mode cString], [self name], - ERRPARAM]; + string = [[OFString alloc] initWithFormat: + @"Failed to open file %s with mode %s in class %s! " ERRFMT, + [path cString], [mode cString], [self name], ERRPARAM]; return string; } - (int)errNo @@ -436,20 +425,17 @@ { if (string != nil) return string;; if (has_items) - string = [[OFMutableString alloc] - initWithFormat: @"Failed to read %zu items of size %zu in " - @"class %s! " ERRFMT, - req_items, req_size, [class name], - ERRPARAM]; + string = [[OFString alloc] initWithFormat: + @"Failed to read %zu items of size %zu in class %s! " + ERRFMT, req_items, req_size, [class name], ERRPARAM]; else - string = [[OFMutableString alloc] - initWithFormat: @"Failed to read %zu bytes in class %s! " - ERRFMT, - req_size, [class name], ERRPARAM]; + string = [[OFString alloc] initWithFormat: + @"Failed to read %zu bytes in class %s! " ERRFMT, req_size, + [class name], ERRPARAM]; return string; } @end @@ -458,20 +444,17 @@ { if (string != nil) return string; if (has_items) - string = [[OFMutableString alloc] - initWithFormat: @"Failed to write %zu items of size %zu in " - @"class %s! " ERRFMT, - req_items, req_size, [class name], - ERRPARAM]; + string = [[OFString alloc] initWithFormat: + @"Failed to write %zu items of size %zu in class %s! " + ERRFMT, req_items, req_size, [class name], ERRPARAM]; else - string = [[OFMutableString alloc] - initWithFormat: @"Failed to write %zu bytes in class %s! " - ERRFMT, - req_size, [class name], ERRPARAM]; + string = [[OFString alloc] initWithFormat: + @"Failed to write %zu bytes in class %s! " ERRFMT, req_size, + [class name], ERRPARAM]; return string; } @end @@ -479,13 +462,12 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"Setting an option in class %s failed!", - [class name]]; + string = [[OFString alloc] initWithFormat: + @"Setting an option in class %s failed!", [class name]]; return string; } @end @@ -493,13 +475,12 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"The socket of type %s is not connected or bound!", - [class name]]; + string = [[OFString alloc] initWithFormat: + @"The socket of type %s is not connected or bound!", [class name]]; return string; } @end @@ -507,15 +488,13 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"The socket of type %s is already connected or " - @"bound and thus can't be connected or bound " - @"again!", - [class name]]; + string = [[OFString alloc] initWithFormat: + @"The socket of type %s is already connected or bound and thus " + @"can't be connected or bound again!", [class name]]; return string; } @end @@ -553,20 +532,17 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"The service %s on %s could not be translated to " - @"an address in class %s. This means that either " - @"the node was not found, there is no such service " - @"on the node, there was a problem with the name " - @"server, there was a problem with your network " - @"connection or you specified an invalid node or " - @"service. " ERRFMT, - [service cString], [node cString], [class name], - AT_ERRPARAM]; + string = [[OFString alloc] initWithFormat: + @"The service %s on %s could not be translated to an address in " + @"class %s. This means that either the node was not found, there " + @"is no such service on the node, there was a problem with the " + @"name server, there was a problem with your network connection " + @"or you specified an invalid node or service. " ERRFMT, + [service cString], [node cString], [class name], AT_ERRPARAM]; return string; } - (int)errNo @@ -619,15 +595,14 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"A connection to service %s on node %s could not " - @"be established in class %s! " ERRFMT, - [node cString], [service cString], [class name], - ERRPARAM]; + string = [[OFString alloc] initWithFormat: + @"A connection to service %s on node %s could not be established " + @"in class %s! " ERRFMT, [node cString], [service cString], + [class name], ERRPARAM]; return string; } - (int)errNo @@ -684,15 +659,14 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"Binding service %s on node %s using family %d " - @"failed in class %s! " ERRFMT, - [service cString], [node cString], family, - [class name], ERRPARAM]; + string = [[OFString alloc] initWithFormat: + @"Binding service %s on node %s using family %d failed in class " + @"%s! " ERRFMT, [service cString], [node cString], family, + [class name], ERRPARAM]; return string; } - (int)errNo @@ -738,14 +712,13 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"Failed to listen in socket of type %s with a " - @"back log of %d! " ERRFMT, - [class name], backlog, ERRPARAM]; + string = [[OFString alloc] initWithFormat: + @"Failed to listen in socket of type %s with a back log of %d! " + ERRFMT, [class name], backlog, ERRPARAM]; return string; } - (int)errNo @@ -772,14 +745,13 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"Failed to accept connection in socket of type " - @"%s! " ERRFMT, - [class name], ERRPARAM]; + string = [[OFString alloc] initWithFormat: + @"Failed to accept connection in socket of type %s! " ERRFMT, + [class name], ERRPARAM]; return string; } - (int)errNo @@ -792,15 +764,13 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"Joining a thread of class %s failed! Most " - @"likely, another thread already waits for the " - @"thread to join.", - [class name]]; + string = [[OFString alloc] initWithFormat: + @"Joining a thread of class %s failed! Most likely, another thread " + @"already waits for the thread to join.", [class name]]; return string; } @end @@ -808,13 +778,12 @@ - (OFString*)string { if (string != nil) return string; - string = [[OFMutableString alloc] - initWithFormat: @"The requested action cannot be performed because " - @"the thread of class %s was canceled!", - [class name]]; + string = [[OFString alloc] initWithFormat: + @"The requested action cannot be performed because the thread of " + @"class %s was canceled!", [class name]]; return string; } @end