@@ -14,35 +14,41 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#include #import "OFUnlockFailedException.h" #import "OFString.h" @implementation OFUnlockFailedException -@synthesize lock = _lock; +@synthesize lock = _lock, errNo = _errNo; + (instancetype)exceptionWithLock: (id )lock + errNo: (int)errNo { - return [[[self alloc] initWithLock: lock] autorelease]; -} - -- (instancetype)init -{ - return [self initWithLock: nil]; + return [[[self alloc] initWithLock: lock + errNo: errNo] autorelease]; } - (instancetype)initWithLock: (id )lock + errNo: (int)errNo { self = [super init]; _lock = [lock retain]; + _errNo = errNo; return self; } + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} - (void)dealloc { [_lock release]; @@ -49,12 +55,10 @@ [super dealloc]; } - (OFString *)description { - if (_lock != nil) - return [OFString stringWithFormat: - @"A lock of type %@ could not be unlocked!", _lock.class]; - else - return @"A lock could not be unlocked!"; + return [OFString stringWithFormat: + @"A lock of type %@ could not be unlocked: %s", + _lock.class, strerror(_errNo)]; } @end