Skip to content

Commit

Permalink
Convert sqlite3 error variables to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
charlievieth committed Dec 23, 2024
1 parent de0a2f1 commit f2431e5
Showing 1 changed file with 82 additions and 82 deletions.
164 changes: 82 additions & 82 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,35 @@ type Error struct {
}

// result codes from http://www.sqlite.org/c3ref/c_abort.html
var (
ErrError = ErrNo(1) /* SQL error or missing database */
ErrInternal = ErrNo(2) /* Internal logic error in SQLite */
ErrPerm = ErrNo(3) /* Access permission denied */
ErrAbort = ErrNo(4) /* Callback routine requested an abort */
ErrBusy = ErrNo(5) /* The database file is locked */
ErrLocked = ErrNo(6) /* A table in the database is locked */
ErrNomem = ErrNo(7) /* A malloc() failed */
ErrReadonly = ErrNo(8) /* Attempt to write a readonly database */
ErrInterrupt = ErrNo(9) /* Operation terminated by sqlite3_interrupt() */
ErrIoErr = ErrNo(10) /* Some kind of disk I/O error occurred */
ErrCorrupt = ErrNo(11) /* The database disk image is malformed */
ErrNotFound = ErrNo(12) /* Unknown opcode in sqlite3_file_control() */
ErrFull = ErrNo(13) /* Insertion failed because database is full */
ErrCantOpen = ErrNo(14) /* Unable to open the database file */
ErrProtocol = ErrNo(15) /* Database lock protocol error */
ErrEmpty = ErrNo(16) /* Database is empty */
ErrSchema = ErrNo(17) /* The database schema changed */
ErrTooBig = ErrNo(18) /* String or BLOB exceeds size limit */
ErrConstraint = ErrNo(19) /* Abort due to constraint violation */
ErrMismatch = ErrNo(20) /* Data type mismatch */
ErrMisuse = ErrNo(21) /* Library used incorrectly */
ErrNoLFS = ErrNo(22) /* Uses OS features not supported on host */
ErrAuth = ErrNo(23) /* Authorization denied */
ErrFormat = ErrNo(24) /* Auxiliary database format error */
ErrRange = ErrNo(25) /* 2nd parameter to sqlite3_bind out of range */
ErrNotADB = ErrNo(26) /* File opened that is not a database file */
ErrNotice = ErrNo(27) /* Notifications from sqlite3_log() */
ErrWarning = ErrNo(28) /* Warnings from sqlite3_log() */
const (
ErrError = ErrNo(C.SQLITE_ERROR) /* SQL error or missing database */
ErrInternal = ErrNo(C.SQLITE_INTERNAL) /* Internal logic error in SQLite */
ErrPerm = ErrNo(C.SQLITE_PERM) /* Access permission denied */
ErrAbort = ErrNo(C.SQLITE_ABORT) /* Callback routine requested an abort */
ErrBusy = ErrNo(C.SQLITE_BUSY) /* The database file is locked */
ErrLocked = ErrNo(C.SQLITE_LOCKED) /* A table in the database is locked */
ErrNomem = ErrNo(C.SQLITE_NOMEM) /* A malloc() failed */
ErrReadonly = ErrNo(C.SQLITE_READONLY) /* Attempt to write a readonly database */
ErrInterrupt = ErrNo(C.SQLITE_INTERRUPT) /* Operation terminated by sqlite3_interrupt() */
ErrIoErr = ErrNo(C.SQLITE_IOERR) /* Some kind of disk I/O error occurred */
ErrCorrupt = ErrNo(C.SQLITE_CORRUPT) /* The database disk image is malformed */
ErrNotFound = ErrNo(C.SQLITE_NOTFOUND) /* Unknown opcode in sqlite3_file_control() */
ErrFull = ErrNo(C.SQLITE_FULL) /* Insertion failed because database is full */
ErrCantOpen = ErrNo(C.SQLITE_CANTOPEN) /* Unable to open the database file */
ErrProtocol = ErrNo(C.SQLITE_PROTOCOL) /* Database lock protocol error */
ErrEmpty = ErrNo(C.SQLITE_EMPTY) /* Database is empty */
ErrSchema = ErrNo(C.SQLITE_SCHEMA) /* The database schema changed */
ErrTooBig = ErrNo(C.SQLITE_TOOBIG) /* String or BLOB exceeds size limit */
ErrConstraint = ErrNo(C.SQLITE_CONSTRAINT) /* Abort due to constraint violation */
ErrMismatch = ErrNo(C.SQLITE_MISMATCH) /* Data type mismatch */
ErrMisuse = ErrNo(C.SQLITE_MISUSE) /* Library used incorrectly */
ErrNoLFS = ErrNo(C.SQLITE_NOLFS) /* Uses OS features not supported on host */
ErrAuth = ErrNo(C.SQLITE_AUTH) /* Authorization denied */
ErrFormat = ErrNo(C.SQLITE_FORMAT) /* Auxiliary database format error */
ErrRange = ErrNo(C.SQLITE_RANGE) /* 2nd parameter to sqlite3_bind out of range */
ErrNotADB = ErrNo(C.SQLITE_NOTADB) /* File opened that is not a database file */
ErrNotice = ErrNo(C.SQLITE_NOTICE) /* Notifications from sqlite3_log() */
ErrWarning = ErrNo(C.SQLITE_WARNING) /* Warnings from sqlite3_log() */
)

// Error return error message from errno.
Expand Down Expand Up @@ -94,57 +94,57 @@ func (err Error) Error() string {
}

// result codes from http://www.sqlite.org/c3ref/c_abort_rollback.html
var (
ErrIoErrRead = ErrIoErr.Extend(1)
ErrIoErrShortRead = ErrIoErr.Extend(2)
ErrIoErrWrite = ErrIoErr.Extend(3)
ErrIoErrFsync = ErrIoErr.Extend(4)
ErrIoErrDirFsync = ErrIoErr.Extend(5)
ErrIoErrTruncate = ErrIoErr.Extend(6)
ErrIoErrFstat = ErrIoErr.Extend(7)
ErrIoErrUnlock = ErrIoErr.Extend(8)
ErrIoErrRDlock = ErrIoErr.Extend(9)
ErrIoErrDelete = ErrIoErr.Extend(10)
ErrIoErrBlocked = ErrIoErr.Extend(11)
ErrIoErrNoMem = ErrIoErr.Extend(12)
ErrIoErrAccess = ErrIoErr.Extend(13)
ErrIoErrCheckReservedLock = ErrIoErr.Extend(14)
ErrIoErrLock = ErrIoErr.Extend(15)
ErrIoErrClose = ErrIoErr.Extend(16)
ErrIoErrDirClose = ErrIoErr.Extend(17)
ErrIoErrSHMOpen = ErrIoErr.Extend(18)
ErrIoErrSHMSize = ErrIoErr.Extend(19)
ErrIoErrSHMLock = ErrIoErr.Extend(20)
ErrIoErrSHMMap = ErrIoErr.Extend(21)
ErrIoErrSeek = ErrIoErr.Extend(22)
ErrIoErrDeleteNoent = ErrIoErr.Extend(23)
ErrIoErrMMap = ErrIoErr.Extend(24)
ErrIoErrGetTempPath = ErrIoErr.Extend(25)
ErrIoErrConvPath = ErrIoErr.Extend(26)
ErrLockedSharedCache = ErrLocked.Extend(1)
ErrBusyRecovery = ErrBusy.Extend(1)
ErrBusySnapshot = ErrBusy.Extend(2)
ErrCantOpenNoTempDir = ErrCantOpen.Extend(1)
ErrCantOpenIsDir = ErrCantOpen.Extend(2)
ErrCantOpenFullPath = ErrCantOpen.Extend(3)
ErrCantOpenConvPath = ErrCantOpen.Extend(4)
ErrCorruptVTab = ErrCorrupt.Extend(1)
ErrReadonlyRecovery = ErrReadonly.Extend(1)
ErrReadonlyCantLock = ErrReadonly.Extend(2)
ErrReadonlyRollback = ErrReadonly.Extend(3)
ErrReadonlyDbMoved = ErrReadonly.Extend(4)
ErrAbortRollback = ErrAbort.Extend(2)
ErrConstraintCheck = ErrConstraint.Extend(1)
ErrConstraintCommitHook = ErrConstraint.Extend(2)
ErrConstraintForeignKey = ErrConstraint.Extend(3)
ErrConstraintFunction = ErrConstraint.Extend(4)
ErrConstraintNotNull = ErrConstraint.Extend(5)
ErrConstraintPrimaryKey = ErrConstraint.Extend(6)
ErrConstraintTrigger = ErrConstraint.Extend(7)
ErrConstraintUnique = ErrConstraint.Extend(8)
ErrConstraintVTab = ErrConstraint.Extend(9)
ErrConstraintRowID = ErrConstraint.Extend(10)
ErrNoticeRecoverWAL = ErrNotice.Extend(1)
ErrNoticeRecoverRollback = ErrNotice.Extend(2)
ErrWarningAutoIndex = ErrWarning.Extend(1)
const (
ErrIoErrRead = ErrNoExtended(ErrIoErr | 1<<8)
ErrIoErrShortRead = ErrNoExtended(ErrIoErr | 2<<8)
ErrIoErrWrite = ErrNoExtended(ErrIoErr | 3<<8)
ErrIoErrFsync = ErrNoExtended(ErrIoErr | 4<<8)
ErrIoErrDirFsync = ErrNoExtended(ErrIoErr | 5<<8)
ErrIoErrTruncate = ErrNoExtended(ErrIoErr | 6<<8)
ErrIoErrFstat = ErrNoExtended(ErrIoErr | 7<<8)
ErrIoErrUnlock = ErrNoExtended(ErrIoErr | 8<<8)
ErrIoErrRDlock = ErrNoExtended(ErrIoErr | 9<<8)
ErrIoErrDelete = ErrNoExtended(ErrIoErr | 10<<8)
ErrIoErrBlocked = ErrNoExtended(ErrIoErr | 11<<8)
ErrIoErrNoMem = ErrNoExtended(ErrIoErr | 12<<8)
ErrIoErrAccess = ErrNoExtended(ErrIoErr | 13<<8)
ErrIoErrCheckReservedLock = ErrNoExtended(ErrIoErr | 14<<8)
ErrIoErrLock = ErrNoExtended(ErrIoErr | 15<<8)
ErrIoErrClose = ErrNoExtended(ErrIoErr | 16<<8)
ErrIoErrDirClose = ErrNoExtended(ErrIoErr | 17<<8)
ErrIoErrSHMOpen = ErrNoExtended(ErrIoErr | 18<<8)
ErrIoErrSHMSize = ErrNoExtended(ErrIoErr | 19<<8)
ErrIoErrSHMLock = ErrNoExtended(ErrIoErr | 20<<8)
ErrIoErrSHMMap = ErrNoExtended(ErrIoErr | 21<<8)
ErrIoErrSeek = ErrNoExtended(ErrIoErr | 22<<8)
ErrIoErrDeleteNoent = ErrNoExtended(ErrIoErr | 23<<8)
ErrIoErrMMap = ErrNoExtended(ErrIoErr | 24<<8)
ErrIoErrGetTempPath = ErrNoExtended(ErrIoErr | 25<<8)
ErrIoErrConvPath = ErrNoExtended(ErrIoErr | 26<<8)
ErrLockedSharedCache = ErrNoExtended(ErrLocked | 1<<8)
ErrBusyRecovery = ErrNoExtended(ErrBusy | 1<<8)
ErrBusySnapshot = ErrNoExtended(ErrBusy | 2<<8)
ErrCantOpenNoTempDir = ErrNoExtended(ErrCantOpen | 1<<8)
ErrCantOpenIsDir = ErrNoExtended(ErrCantOpen | 2<<8)
ErrCantOpenFullPath = ErrNoExtended(ErrCantOpen | 3<<8)
ErrCantOpenConvPath = ErrNoExtended(ErrCantOpen | 4<<8)
ErrCorruptVTab = ErrNoExtended(ErrCorrupt | 1<<8)
ErrReadonlyRecovery = ErrNoExtended(ErrReadonly | 1<<8)
ErrReadonlyCantLock = ErrNoExtended(ErrReadonly | 2<<8)
ErrReadonlyRollback = ErrNoExtended(ErrReadonly | 3<<8)
ErrReadonlyDbMoved = ErrNoExtended(ErrReadonly | 4<<8)
ErrAbortRollback = ErrNoExtended(ErrAbort | 2<<8)
ErrConstraintCheck = ErrNoExtended(ErrConstraint | 1<<8)
ErrConstraintCommitHook = ErrNoExtended(ErrConstraint | 2<<8)
ErrConstraintForeignKey = ErrNoExtended(ErrConstraint | 3<<8)
ErrConstraintFunction = ErrNoExtended(ErrConstraint | 4<<8)
ErrConstraintNotNull = ErrNoExtended(ErrConstraint | 5<<8)
ErrConstraintPrimaryKey = ErrNoExtended(ErrConstraint | 6<<8)
ErrConstraintTrigger = ErrNoExtended(ErrConstraint | 7<<8)
ErrConstraintUnique = ErrNoExtended(ErrConstraint | 8<<8)
ErrConstraintVTab = ErrNoExtended(ErrConstraint | 9<<8)
ErrConstraintRowID = ErrNoExtended(ErrConstraint | 10<<8)
ErrNoticeRecoverWAL = ErrNoExtended(ErrNotice | 1<<8)
ErrNoticeRecoverRollback = ErrNoExtended(ErrNotice | 2<<8)
ErrWarningAutoIndex = ErrNoExtended(ErrWarning | 1<<8)
)

0 comments on commit f2431e5

Please sign in to comment.