Обработка исключений

void throwIfTrue(bool param) {
    //no "else" for @try: the tail of
    //the block runs only when nothing
    //was raised
    @try {
        if (param) {
            @throw [NSException
                exceptionWithName:@"Test"
                reason:@"test"
                userInfo:nil];
        }
        NSLog(@"else");
    }
    @catch (NSException *e) {
        NSLog(@"except");
    }
}

throwIfTrue(true);
//printed: 'except'

throwIfTrue(false);
//printed only 'else'