Skip to content

Add getters to sqlite3.Error #1324

@abemedia

Description

@abemedia

I'm working on a library which works with many different SQL drivers and maps to common errors for things like unique constraints etc.
I'd like to avoid having to import go-sqlite3 as it requires cgo so I was wondering whether you'd be open to adding getters for the error which can be used in a more dynamic environment e.g.

// Error implement sqlite error code.
type Error struct {
	Code         ErrNo         /* The error code returned by SQLite */
	ExtendedCode ErrNoExtended /* The extended error code returned by SQLite */
	SystemErrno  syscall.Errno /* The system errno returned by the OS through SQLite, if applicable */
	err          string        /* The error string returned by sqlite3_errmsg(),
	this usually contains more specific details. */
}


func (err Error) GetExtendedCode() int {
	return int(err.ExtendedCode)
}

That way libraries that need to support go-sqlite3 can do so without relying on the package by simply using an interface.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions