From d0c551acb5ab79efafd325f5b19c76a3de835356 Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 5 Nov 2025 21:58:38 +0100 Subject: [chore] update dependencies (#4542) - github.com/minio/minio-go/v7: v7.0.95 -> v7.0.97 - github.com/ncruces/go-sqlite3: v0.29.1 -> v0.30.0 - github.com/tdewolff/minify/v2: v2.24.5 -> v2.24.6 - codeberg.org/gruf/go-mmap: fixes build for BSD platforms Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4542 Co-authored-by: kim Co-committed-by: kim --- vendor/github.com/ncruces/go-sqlite3/error.go | 36 ++++++++++++++++++++------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'vendor/github.com/ncruces/go-sqlite3/error.go') diff --git a/vendor/github.com/ncruces/go-sqlite3/error.go b/vendor/github.com/ncruces/go-sqlite3/error.go index 83b057d0d..8d0419c51 100644 --- a/vendor/github.com/ncruces/go-sqlite3/error.go +++ b/vendor/github.com/ncruces/go-sqlite3/error.go @@ -11,6 +11,7 @@ import ( // // https://sqlite.org/c3ref/errcode.html type Error struct { + sys error msg string sql string code res_t @@ -33,16 +34,28 @@ func (e *Error) ExtendedCode() ExtendedErrorCode { // Error implements the error interface. func (e *Error) Error() string { var b strings.Builder - b.WriteString(util.ErrorCodeString(uint32(e.code))) + b.WriteString(util.ErrorCodeString(e.code)) if e.msg != "" { b.WriteString(": ") b.WriteString(e.msg) } + if e.sys != nil { + b.WriteString(": ") + b.WriteString(e.sys.Error()) + } return b.String() } +// Unwrap returns the underlying operating system error +// that caused the I/O error or failure to open a file. +// +// https://sqlite.org/c3ref/system_errno.html +func (e *Error) Unwrap() error { + return e.sys +} + // Is tests whether this error matches a given [ErrorCode] or [ExtendedErrorCode]. // // It makes it possible to do: @@ -90,7 +103,16 @@ func (e *Error) SQL() string { // Error implements the error interface. func (e ErrorCode) Error() string { - return util.ErrorCodeString(uint32(e)) + return util.ErrorCodeString(e) +} + +// As converts this error to an [ExtendedErrorCode]. +func (e ErrorCode) As(err any) bool { + c, ok := err.(*xErrorCode) + if ok { + *c = xErrorCode(e) + } + return ok } // Temporary returns true for [BUSY] errors. @@ -105,7 +127,7 @@ func (e ErrorCode) ExtendedCode() ExtendedErrorCode { // Error implements the error interface. func (e ExtendedErrorCode) Error() string { - return util.ErrorCodeString(uint32(e)) + return util.ErrorCodeString(e) } // Is tests whether this error matches a given [ErrorCode]. @@ -150,14 +172,10 @@ func errorCode(err error, def ErrorCode) (msg string, code res_t) { return code.msg, res_t(code.code) } - var ecode ErrorCode var xcode xErrorCode - switch { - case errors.As(err, &xcode): + if errors.As(err, &xcode) { code = res_t(xcode) - case errors.As(err, &ecode): - code = res_t(ecode) - default: + } else { code = res_t(def) } return err.Error(), code -- cgit v1.2.3