Skip to content

Commit

Permalink
Merge pull request marcoarment#11 from jgallagher/fix-error-message
Browse files Browse the repository at this point in the history
Save FMDB errors before calling -rollback. (Nice find.)
  • Loading branch information
marcoarment committed Oct 10, 2013
2 parents afcc702 + ed1f1d1 commit e76a121
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ NSString *dbPath = [documentsPath stringByAppendingPathComponent:@"testDB.sqlite

// My custom failure handling. Yours may vary.
void (^failedAt)(int statement) = ^(int statement){
int lastErrorCode = db.lastErrorCode;
NSString *lastErrorMessage = db.lastErrorMessage;
[db rollback];
NSAssert3(0, @"Migration statement %d failed, code %d: %@", statement, db.lastErrorCode, db.lastErrorMessage);
NSAssert3(0, @"Migration statement %d failed, code %d: %@", statement, lastErrorCode, lastErrorMessage);
};

if (*schemaVersion < 1) {
Expand Down
4 changes: 3 additions & 1 deletion example/FCModelTest Tests/FCModelTest_Tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ - (void)openDatabase
[db beginTransaction];

void (^failedAt)(int statement) = ^(int statement){
int lastErrorCode = db.lastErrorCode;
NSString *lastErrorMessage = db.lastErrorMessage;
[db rollback];
NSAssert3(0, @"Migration statement %d failed, code %d: %@", statement, db.lastErrorCode, db.lastErrorMessage);
NSAssert3(0, @"Migration statement %d failed, code %d: %@", statement, lastErrorCode, lastErrorMessage);
};

if (*schemaVersion < 1) {
Expand Down
4 changes: 3 additions & 1 deletion example/FCModelTest/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[db beginTransaction];

void (^failedAt)(int statement) = ^(int statement){
int lastErrorCode = db.lastErrorCode;
NSString *lastErrorMessage = db.lastErrorMessage;
[db rollback];
NSAssert3(0, @"Migration statement %d failed, code %d: %@", statement, db.lastErrorCode, db.lastErrorMessage);
NSAssert3(0, @"Migration statement %d failed, code %d: %@", statement, lastErrorCode, lastErrorMessage);
};

if (*schemaVersion < 1) {
Expand Down

0 comments on commit e76a121

Please sign in to comment.