DatabaseError
public struct DatabaseError : Error, CustomStringConvertible, CustomNSError
DatabaseError wraps an SQLite error.
-
The SQLite error code (see https://www.sqlite.org/rescode.html#primary_result_code_list).
do { ... } catch let error as DatabaseError where error.resultCode == .SQL_CONSTRAINT { // A constraint error }
This property returns a
primary result code
, that is to say the least significant 8 bits of any SQLite result code. See https://www.sqlite.org/rescode.html for more information.See also
extendedResultCode
.Declaration
Swift
public var resultCode: ResultCode { get }
-
The SQLite extended error code (see https://www.sqlite.org/rescode.html#extended_result_code_list).
do { ... } catch let error as DatabaseError where error.extendedResultCode == .SQLITE_CONSTRAINT_FOREIGNKEY { // A foreign key constraint error }
See also
resultCode
.Declaration
Swift
public let extendedResultCode: ResultCode
-
The SQLite error message.
Declaration
Swift
public let message: String?
-
The SQL query that yielded the error (if relevant).
Declaration
Swift
public let sql: String?
-
Creates a Database Error
Declaration
Swift
public init( resultCode: ResultCode = .SQLITE_ERROR, message: String? = nil, sql: String? = nil, arguments: StatementArguments? = nil)