Browse Source

Add extended error code

Expose `sqlite3_extended_errcode` API.
Robert M. Ryan 9 years ago
parent
commit
23744bdeba
2 changed files with 23 additions and 3 deletions
  1. 19 3
      src/fmdb/FMDatabase.h
  2. 4 0
      src/fmdb/FMDatabase.m

+ 19 - 3
src/fmdb/FMDatabase.h

@@ -834,17 +834,33 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary
 /** Last error code
 /** Last error code
  
  
  Returns the numeric result code or extended result code for the most recent failed SQLite API call associated with a database connection. If a prior API call failed but the most recent API call succeeded, this return value is undefined.
  Returns the numeric result code or extended result code for the most recent failed SQLite API call associated with a database connection. If a prior API call failed but the most recent API call succeeded, this return value is undefined.
-
+ 
  @return Integer value of the last error code.
  @return Integer value of the last error code.
-
+ 
  @see [sqlite3_errcode()](http://sqlite.org/c3ref/errcode.html)
  @see [sqlite3_errcode()](http://sqlite.org/c3ref/errcode.html)
  @see lastErrorMessage
  @see lastErrorMessage
  @see lastError
  @see lastError
-
+ 
  */
  */
 
 
 - (int)lastErrorCode;
 - (int)lastErrorCode;
 
 
+/** Last extended error code
+ 
+ Returns the numeric extended result code for the most recent failed SQLite API call associated with a database connection. If a prior API call failed but the most recent API call succeeded, this return value is undefined.
+ 
+ @return Integer value of the last extended error code.
+ 
+ @see [sqlite3_errcode()](http://sqlite.org/c3ref/errcode.html)
+ @see [2. Primary Result Codes versus Extended Result Codes](http://sqlite.org/rescode.html#primary_result_codes_versus_extended_result_codes)
+ @see [5. Extended Result Code List](http://sqlite.org/rescode.html#extrc)
+ @see lastErrorMessage
+ @see lastError
+ 
+ */
+
+- (int)lastExtendedErrorCode;
+
 /** Had error
 /** Had error
 
 
  @return `YES` if there was an error, `NO` if no error.
  @return `YES` if there was an error, `NO` if no error.

+ 4 - 0
src/fmdb/FMDatabase.m

@@ -500,6 +500,10 @@ - (int)lastErrorCode {
     return sqlite3_errcode(_db);
     return sqlite3_errcode(_db);
 }
 }
 
 
+- (int)lastExtendedErrorCode {
+    return sqlite3_extended_errcode(_db);
+}
+
 - (NSError*)errorWithMessage:(NSString*)message {
 - (NSError*)errorWithMessage:(NSString*)message {
     NSDictionary* errorMessage = [NSDictionary dictionaryWithObject:message forKey:NSLocalizedDescriptionKey];
     NSDictionary* errorMessage = [NSDictionary dictionaryWithObject:message forKey:NSLocalizedDescriptionKey];