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 ¶
HandleError converts a database/sql error into an *errorx.AppError, or returns nil if err is nil. table may be empty.
func IsNotFound ¶
IsNotFound reports whether the query returned no rows.
func IsRetryable ¶
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.