diff options
Diffstat (limited to 'vendor/github.com/mattn/go-sqlite3/error.go')
-rw-r--r-- | vendor/github.com/mattn/go-sqlite3/error.go | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/vendor/github.com/mattn/go-sqlite3/error.go b/vendor/github.com/mattn/go-sqlite3/error.go index 49ab890366..696281c733 100644 --- a/vendor/github.com/mattn/go-sqlite3/error.go +++ b/vendor/github.com/mattn/go-sqlite3/error.go @@ -1,11 +1,19 @@ -// Copyright (C) 2014 Yasuhiro Matsumoto <mattn.jp@gmail.com>. +// Copyright (C) 2019 Yasuhiro Matsumoto <mattn.jp@gmail.com>. // // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. package sqlite3 +/* +#ifndef USE_LIBSQLITE3 +#include <sqlite3-binding.h> +#else +#include <sqlite3.h> +#endif +*/ import "C" +import "syscall" // ErrNo inherit errno. type ErrNo int @@ -20,6 +28,7 @@ type ErrNoExtended int 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. */ } @@ -72,10 +81,16 @@ func (err ErrNoExtended) Error() string { } func (err Error) Error() string { + var str string if err.err != "" { - return err.err + str = err.err + } else { + str = C.GoString(C.sqlite3_errstr(C.int(err.Code))) } - return errorString(err) + if err.SystemErrno != 0 { + str += ": " + err.SystemErrno.Error() + } + return str } // result codes from http://www.sqlite.org/c3ref/c_abort_rollback.html |