sql

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sql converts database/sql failures into an errorx.AppError without depending on any driver.

It is the fallback for stores errorx has no dedicated adapter for. It knows only what the standard library exposes — the sql sentinels, context cancellation, and network failures — so it cannot tell a duplicate key from a deadlock. Where a dedicated adapter exists (postgres, mysql, clickhouse), use it: the difference between "retry this" and "this will never work" lives in the driver's own error codes, and this package cannot see them.

import sqlx "github.com/bakhod1r/errorx/adapter/sql"

if err := row.Scan(&u.ID); err != nil {
	return sqlx.HandleError(err, "users", nil)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleError

func HandleError(err error, table string, extraFields map[string]any) *errorx.AppError

HandleError converts a database/sql error into an *errorx.AppError, or returns nil if err is nil. table may be empty.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether the query returned no rows.

func IsRetryable

func IsRetryable(err error) bool

IsRetryable reports whether err is worth retrying, according to the registry policy of the code it classifies into.

Without driver codes this can only recognize connection and timeout failures. A deadlock, which is the most worthwhile thing to retry, reaches here as an opaque driver error and reports false.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL