@@ -14,36 +14,42 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#include #import "OFThreadStartFailedException.h" #import "OFString.h" #import "OFThread.h" @implementation OFThreadStartFailedException -@synthesize thread = _thread; +@synthesize thread = _thread, errNo = _errNo; + (instancetype)exceptionWithThread: (OFThread *)thread + errNo: (int)errNo { - return [[[self alloc] initWithThread: thread] autorelease]; -} - -- (instancetype)init -{ - return [self initWithThread: nil]; + return [[[self alloc] initWithThread: thread + errNo: errNo] autorelease]; } - (instancetype)initWithThread: (OFThread *)thread + errNo: (int)errNo { self = [super init]; _thread = [thread retain]; + _errNo = errNo; return self; } + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} - (void)dealloc { [_thread release]; @@ -50,12 +56,10 @@ [super dealloc]; } - (OFString *)description { - if (_thread != nil) - return [OFString stringWithFormat: - @"Starting a thread of type %@ failed!", _thread.class]; - else - return @"Starting a thread failed!"; + return [OFString stringWithFormat: + @"Starting a thread of type %@ failed: %s", + _thread.class, strerror(_errNo)]; } @end