Use exceptions.
This commit is contained in:
parent
fa34006321
commit
8f4e29a466
5 changed files with 234 additions and 41 deletions
20
src/XMPPIQ.m
20
src/XMPPIQ.m
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue