Repository: realm/realm-swift
File: src/tightdb/objc/TDBContext.mm (Objective-C++)

Code before:
                                                       userInfo:[NSMutableDictionary dictionary]];  // IMPORTANT: cannot not be nil !!
        [exception raise];
    }

    @try {
        // No TightDB Obj-C methods used in the block
        // should throw anything but NSException or derivatives. Note: if the client calls other libraries
        // throwing other kinds of exceptions they will leak back to the client code, if he does not
        // catch them within the block.
        TDBTransaction* group_2 = [TDBTransaction groupWithNativeGroup:const_cast<tightdb::Group*>(group) isOwned:NO readOnly:YES];
        block(group_2);

    }
    @finally {
        m_shared_group->end_read();
    }
}

-(void)readTable:(NSString*)tablename withBlock:(TDBTableReadBlock)block
{
    [self readWithBlock:^(TDBTransaction* trx){
        TDBTable *table = [trx tableWithName:tablename];
        block(table);
    }];
}


-(BOOL)writeWithBlock:(TDBWriteBlock)block error:(NSError**)error
{
    tightdb::Group* group;
    try {
        group = &m_shared_group->begin_write();
    }
    catch (std::exception& ex) {
        // File access errors are treated as exceptions here since they should not occur after the shared
        // group has already beenn successfully opened on the file and memeory mapped. The shared group constructor handles
        // the excepted error related to file access.
        NSException* exception = [NSException exceptionWithName:@"tightdb:core_exception"
                                                         reason:[NSString stringWithUTF8String:ex.what()]
                                                       userInfo:[NSMutableDictionary dictionary]];
        [exception raise];
    }

    BOOL confirmation = NO;
    @try {
        TDBTransaction* group_2 = [TDBTransaction groupWithNativeGroup:group isOwned:NO readOnly:NO];
        confirmation = block(group_2);
    }
    @catch (NSException* exception) {
        m_shared_group->rollback();
        @throw;

Review comment (suggestion):
Inconsistent `*` placement in your types (above and below).


Code after:
                                                       userInfo:[NSMutableDictionary dictionary]];  // IMPORTANT: cannot not be nil !!
        [exception raise];
    }

    @try {
        // No TightDB Obj-C methods used in the block
        // should throw anything but NSException or derivatives. Note: if the client calls other libraries
        // throwing other kinds of exceptions they will leak back to the client code, if he does not
        // catch them within the block.
        TDBTransaction* group_2 = [TDBTransaction groupWithNativeGroup:const_cast<tightdb::Group*>(group) isOwned:NO readOnly:YES];
        block(group_2);

    }
    @finally {
        m_shared_group->end_read();
    }
}

-(void)readTable:(NSString*)tablename withBlock:(TDBTableReadBlock)block
{
    [self readWithBlock:^(TDBTransaction *trx){
        TDBTable *table = [trx tableWithName:tablename];
        block(table);
    }];
}


-(BOOL)writeWithBlock:(TDBWriteBlock)block error:(NSError**)error
{
    tightdb::Group* group;
    try {
        group = &m_shared_group->begin_write();
    }
    catch (std::exception& ex) {
        // File access errors are treated as exceptions here since they should not occur after the shared
        // group has already beenn successfully opened on the file and memeory mapped. The shared group constructor handles
        // the excepted error related to file access.
        NSException* exception = [NSException exceptionWithName:@"tightdb:core_exception"
                                                         reason:[NSString stringWithUTF8String:ex.what()]
                                                       userInfo:[NSMutableDictionary dictionary]];
        [exception raise];
    }

    BOOL confirmation = NO;
    @try {
        TDBTransaction* group_2 = [TDBTransaction groupWithNativeGroup:group isOwned:NO readOnly:NO];
        confirmation = block(group_2);
    }
    @catch (NSException* exception) {
        m_shared_group->rollback();
        @throw;