@@ -30,10 +30,19 @@ } + (instancetype)exceptionWithStream: (OFSeekableStream *)stream offset: (of_offset_t)offset whence: (int)whence +{ + return [[[self alloc] initWithStream: stream + offset: offset + whence: whence] autorelease]; +} + ++ (instancetype)exceptionWithStream: (OFSeekableStream *)stream + offset: (of_offset_t)offset + whence: (int)whence errNo: (int)errNo { return [[[self alloc] initWithStream: stream offset: offset whence: whence @@ -42,10 +51,23 @@ - init { OF_INVALID_INIT_METHOD } + +- initWithStream: (OFSeekableStream *)stream + offset: (of_offset_t)offset + whence: (int)whence +{ + self = [super init]; + + _stream = [stream retain]; + _offset = offset; + _whence = whence; + + return self; +} - initWithStream: (OFSeekableStream *)stream offset: (of_offset_t)offset whence: (int)whence errNo: (int)errNo @@ -67,10 +89,14 @@ [super dealloc]; } - (OFString *)description { - return [OFString stringWithFormat: - @"Seeking failed in stream of type %@: %@", - [_stream class], of_strerror(_errNo)]; + if (_errNo != 0) + return [OFString stringWithFormat: + @"Seeking failed in stream of type %@: %@", + [_stream class], of_strerror(_errNo)]; + else + return [OFString stringWithFormat: + @"Seeking failed in stream of type %@!", [_stream class]]; } @end