Use exceptions.

This commit is contained in:
Jonathan Schleifer 2011-02-16 23:36:50 +01:00
parent fa34006321
commit 8f4e29a466
5 changed files with 234 additions and 41 deletions

View file

@ -34,14 +34,20 @@
- initWithType: (OFString*)type_
ID: (OFString*)ID_
{
if (![type_ isEqual: @"get"] &&
![type_ isEqual: @"set"] &&
![type_ isEqual: @"result"] &&
![type_ isEqual: @"error"])
of_log(@"Invalid IQ type!");
return [super initWithName: @"iq"
self = [super initWithName: @"iq"
type: type_
ID: ID_];
@try {
if (![type_ isEqual: @"get"] && ![type_ isEqual: @"set"] &&
![type_ isEqual: @"result"] && ![type_ isEqual: @"error"])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
@end