Skip to content

Commit

Permalink
fixed error domain behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
dodikk committed May 7, 2012
1 parent ccee9b6 commit f0bf7d2
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/FMDatabase.m
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,20 @@ - (int)lastErrorCode {
return sqlite3_errcode(_db);
}

- (NSError*)lastError {
return [NSError errorWithDomain:@"FMDatabase" code:sqlite3_errcode(_db) userInfo:[NSDictionary dictionaryWithObject:[self lastErrorMessage] forKey:NSLocalizedDescriptionKey]];

-(NSError*)errorWithMessage:( NSString* )message_
{
NSDictionary* errorMessage_ = [ NSDictionary dictionaryWithObject: message_
forKey: NSLocalizedDescriptionKey];

return [NSError errorWithDomain:@"FMDatabase"
code:sqlite3_errcode(_db)
userInfo:errorMessage_];
}

-(NSError*)lastError
{
return [ self errorWithMessage: [ self lastErrorMessage ] ];
}

- (sqlite_int64)lastInsertRowId {
Expand Down Expand Up @@ -725,7 +737,10 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra
sqlite3_finalize(pStmt);

if (outErr) {
*outErr = [NSError errorWithDomain:[NSString stringWithUTF8String:sqlite3_errmsg(_db)] code:rc userInfo:nil];



*outErr = [ self errorWithMessage: [NSString stringWithUTF8String:sqlite3_errmsg(_db)] ];
}

_isExecutingStatement = NO;
Expand Down

0 comments on commit f0bf7d2

Please sign in to comment.